In a Django app I have a class that extends AbstractUser:
class CustomUser(AbstractUser):
uid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
...more fields that are not in the parent...
When I look at the /admin/ I see that the parent fields are on top, and it looks really bad, with the password being the first field. How do I put the child fields on top?
You can sort the fields by overriding UserAdmin:
from django.contrib.auth.admin import UserAdmin
@admin.register(User)
class CustomUserAdmin(UserAdmin):
fieldsets = (
(
('Personal information'),
{'fields': ('first_name', 'last_name', 'email')}
)
)
The above code will create a section called Personal information
which will have the fields first_name
, last_name
and email
.