djangocms-cascade
djangocms-cascade copied to clipboard
optional render horizontal with EntangledModelFormMixin class
In this image "Adapt Picture Zoom" is inline. ( save in List) I want to display forms EntangledModelFormMixinclass in inlines. (save in FiedJson)
what would be the best approach?
by modifying admin/change_form.html
and adding css logic on widgets this might be feasible, perhaps.
Actually, it is not possible to put custom css classes and access formset on forms, only on widgets.
The ideal will be responsive, inline if logic media-query.
For now, we could add a color border to the form to delimit some of the FormMixins.
Yes, this was one of the drawbacks I encountered, after I introduced django-entangled to Cascade. First I didn't find any quick solution for it, later I got used to it, and since the popping up plugin editors remain quite slim, it can even be considered as an advantage that a user only has to scroll vertically, but not horizontally. What do you think?
There is a quick fix with the fieldset attribute. Its format simply allows it, parentheses take care of everything. And a little css to tweak for help if we need.
1 none) vertical 2 none) horizontal 3 none) mixed
fieldsets = (
(None, {
'classes': ('custom_help',),
'fields': (
('some_fields'),('some_fields1'), ('some_fields2')
),
}),
(None, {
'classes': ('custom_help'),
'fields': (
('some_fields3','some_fields4', 'some_fields5'),
),
}),
(None, {
'classes': ('custom_help',),
'fields': (
('some_fields6',('some_fields7')), ('some_fields8')
),
}),
)
With from django.contrib.admin.options import flatten_fieldsets
, there might be logic if in Meta there are an attribute entangled_fieldset is present:
class MixedHorizantalVerticalFormMixin(EntangledModelFormMixin):
class Meta
entangled_fieldset=( None, { "fields" : (('some_fields1',
'some_fields2','some_fields3'), 'some_fields6', 'some_fields5')})
#Otpional default: 'glossary'
entangled_glossary_key='glossary'
...
from django.contrib.admin.options import flatten_fieldsets
...
class EntangledFormMetaclass(ModelFormMetaclass):
def __new__(cls, class_name, bases, attrs, ):
...
entangled_fields=flatten_fieldsets((entangled_fieldset,))
# ['some_fields1', 'some_fields2','some_fields3', 'some_fields6', 'some_fields5']
...
Or rather, make entangled_fields accept the tuple format: I'm thinking of pulling a pull-request for django-entangled in this way.
class Meta:
entangled_fields = {'glossary': (('some_field1', ''some_field2', 'some_field3',) 'some_field4', ''some_field5')}
OK, now I see what you mean.
So basically you want django-entangled to behave similar to django.contrib.admin
using fieldsets.
Yes, this would be a useful feature. The pull request then should go against django-entangled.
BTW: tuples. For readability, use them rarely. I only use them, if I want to signalize that the interacting API really expects that exact number of elements, rather than a variable list of elements. This for instance would be the tuples inside a list of choices.