How do you order users in the django admin panel so that upon display they are ordered by date created? Currently they are listed in alphabetical order
I know that I can import the
from django.contrib.auth.models import User
To change the default ordering of users in admin panel you can subclass the default UserAdmin class. In your applications's
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User class MyUserAdmin(UserAdmin): # override the default sort column ordering = ('date_joined', ) # if you want the date they joined or other columns displayed in the list, # override list_display too list_display = ('username', 'email', 'date_joined', 'first_name', 'last_name', 'is_staff') # finally replace the default UserAdmin with yours admin.site.unregister(User) admin.site.register(User, MyUserAdmin)
For more information refer to the documentation.