I'm pretty new to Django and experimenting with it.
I've read a quite amount of docs about the framework but I could not find information on how to "group" fields in admin forms.
What I mean by grouping is having an arbitrary number of fields grouped under an arbitrary subsection (the way the subsection is represented graphically is not important).
Is it possible to "natively" do that (by natively, I mean without overriding any Admin Form)?
Set the exclude attribute of the ModelForm 's inner Meta class to a list of fields to be excluded from the form.
Making Fields Required In Django Admin In order to make the summary field required, we need to create a custom form for the Post model. I am making them on the same file you can do this on a separate forms.py file as well.
These field classes are only maintained for legacy purposes. They aren't recommended as comma separation is a fragile serialization format. For new uses, you're better off using Django 3.1's JSONField that works with all database backends.
You can do this with fieldsets.
For example:
class MyModelAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('field1', 'field2', 'field3')
}),
('Advanced options', {
'fields': ('field4', 'field5'),
}),
)
See the docs for more information.
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