2👍
I had the same problem and solved it by:
Add ordering attribute in the admin.py like:
class staffAdmin(UserAdmin):
list_display = ('location', 'staff_number')
search_field = ('location', 'staff_number')
filter_horizontal = ()
list_filter = ()
fieldsets = ()
**ordering = ('username',)**
0👍
Update:
My django ver: 4.2
Solution:
As per django docs, the solution is simple. Just add an ordering field too.
Link:
https://docs.djangoproject.com/en/4.2/topics/auth/customizing/
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from .models import CustomUser
@admin.register(CustomUser)
class CustomUserAdmin(BaseUserAdmin):
list_display = ["email", "is_staff"]
ordering = ["email"]
- [Answered ]-Django-cms: link to plugin with hashtag
- [Answered ]-Vanilla Django Query to show 'flattened' User/Group (ManyToMany) Listing
- [Answered ]-Creating an API using Django-Rest-Framework with join tables
- [Answered ]-Django KeyError: 'password'
-1👍
ok i see
if you’re not in production try to delete your database
and run
manage.py makemigrations
manage.py migrate
- [Answered ]-How can I keep 'username' after deleting user in django?
- [Answered ]-Django TrigramSimilarity error for searches
- [Answered ]-AttributeError: 'unicode' object has no attribute '_meta'
- [Answered ]-Kind of complex query in Django with annotate
- [Answered ]-Django: RecursionError when initialize a object
Source:stackexchange.com