[Fixed]-Ordering the display items alphabetically in Django-Admin

27👍

Set ModelAdmin.ordering = ('foo', ) to order your admin.

Example

class TeamRoleAdmin(admin.ModelAdmin):
   """ Team Role admin view with modifications """
   model = TeamRole
   ordering = ('team', 'role', 'user')
   list_display = ['id', 'user', 'team', 'role']

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering

Modify global model meta class, override ModelAdmin.queryset, there are many ways but you most likely want the Admin ordering.

4👍

In your models Meta you can specify ordering = ['first_name', 'last_name'].

👤Rohan

Leave a comment