[Fixed]-Django error admin.E033: username is not an attribute of users.CustomUser. Why is my custom user admin not working?

46👍

Like the error says, the admin class for User by default orders by username. Since you don’t have a username, you should override that:

class CustomUserAdmin(BaseUserAdmin):
    ...
    ordering = ('email',)

2👍

class CustomUserAdmin(BaseUserAdmin):
        ordering = ("any field in  list_display")
👤kamula

Leave a comment