Can I show a grouped result in Django Admin? By default, they are showing all rows, I want to group these rows based on some fields, and display it.
Something like "GROUP BY username" or stuff. I've tried to search but no luck :(
Can I show a grouped result in Django Admin? By default, they are showing all rows, I want to group these rows based on some fields, and display it.
Something like "GROUP BY username" or stuff. I've tried to search but no luck :(
What about using list_filter='my_field'
in the admin.py file ?
Yes, you can.
this applies to the detail view of the records. Here is an example listed below.
class GroupAdmin(admin.ModelAdmin):
form = SpecieForm
list_display = ('species', 'latin_name', 'family', 'status')
search_fields = ['species', 'latin_name']
prepopulated_fields = { 'slug': ['species'] }
fieldsets = [
(None, {'fields': ['field1', 'field2', 'field3', 'field4']}),
('Image', {'fields': ['original_image']}),
('Other Group', {'fields': ['other_field1', 'other_field2', 'other_field3', 'other_field4']}),
]
admin.site.register(Group, GroupAdmin)
Hope this helps.