Only add_fieldsets
is enough. No need to provide the add_form
.
this would be the full code for admin.py
, you can read about it in the Django docs here
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
class UserAdmin(UserAdmin):
add_fieldsets = (
(
None,
{
'classes': ('wide',),
'fields': ('username', 'email', 'password1', 'password2'),
},
),
)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
As a side note: 'classes':('wide',),
sets the style of the field to open or "not collapsed", you can read more about the options for that here