I'm just starting out with Django writing my first app - a chore chart manager for my family. In the tutorial it shows you how to add related objects in a tabular form. I don't care about the related objects, I just want to add the regular object in a tabular form. This is what I have in my admin.py
from chores.models import Chore
from django.contrib import admin
class ChoreAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['description', 'frequency', 'person']})
]
admin.site.register(Chore, ChoreAdmin)
and I want when I click "add chore" that rather than seeing:
Description: _____
Frequency: ______
Person: _____
I want it to show:
Description: __________ | Frequency: _______ | Person: _____
Is this trivial to do, or would it take a lot of custom effort? And if it is easy, how do I do it?
Thanks!
OP is probably all set, but for new users reading this, refer to: https://docs.djangoproject.com/en/dev/ref/contrib/admin/
Basically following part in above link:
The field_options
dictionary can have the following keys:
fields
: A tuple of field names to display in this fieldset. This key is required.
Example:
{
'fields': ('first_name', 'last_name', 'address', 'city', 'state'),
}
Just like with the fields
option, to display multiple fields on the same line, wrap those fields in their own tuple. In this example, the first_name
and last_name
fields will display on the same line:
{
'fields': (('first_name', 'last_name'), 'address', 'city', 'state'),
}
Something to try,
class ChoreAdmin(admin.ModelAdmin):
list_display = ('description', 'frequency', 'person')
list_editable = ('description', 'frequency', 'person')
Which should enable you to edit all your entries in a tabular form (if I've read the docs correctly)...
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