How do I get Django admin to display groups horizontally? If I have 3 adjacent datetime fields, I'd rather them take up 1 row, not 3.
Have you tried grouping your fieldsets into tuples?:
fieldsets = (
(None, {
'fields': ('name','description',('start_date','end_date'), 'location', ('latitude','longitude'))
}),
)
The way I've done it is to make a custom admin template. You can just take the one that comes with django, copy it, and edit the parts you want changed.
A good tutorial on how to do that is on the django site. Specifically, there is a part on making a custom admin template.
It is been tested on Django==2.0.7 and worked like a charm, a really important piece of advice regarding the use of the param "fieldsets" is that u cant use "fields" property at same time , otherwise u will get the following error on ur console :
(admin.E005) Both 'fieldsets' and 'fields' are specified.
The syntax would be smth like these :
fieldsets = (
('General Information', {
'fields': (
("id", "created_at", "updated_at",),
("name", "coupon_type", "discount", "is_active",),
("quantity", "minumum_quantity", "before_expire",),
),
}),
('Expiration Dates', {
'fields': (
("expiration_from", "expiration_to",),
),
}),
('Grants for', {
'fields': (
"products", "campaigns_product", "sellers", "platforms",
),
}),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With