I have a simple model of a Student
which is registered to the admin through a admin.ModelAdmin
.
The admin change form of this model looks like this:
I'd like to change the layout of this form a little so that a few fields could be in the same line, like so (edited in Paint):
Is there something I could do without overriding the default templates? And if there isn't, what's the best way?
Thanks in advance.
You can use fields
attribute in ModelAdmin
like this:
@admin.register(Student)
class StudentAdmin(admin.ModelAdmin):
fields = (
('no_student', 'last_name', 'first_name),
'course',
'sex',
'id'
)
Fields grouped in one sub-tuple or sub-list will be shown in one line. You can create more than one groups like this.
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