customized form added to the admin interface for the user

This commit is contained in:
Chneemann 2024-08-04 08:57:10 +02:00
parent 6743153be0
commit f8af9ee5df
2 changed files with 26 additions and 1 deletions

View file

@ -1,4 +1,22 @@
from django.contrib import admin
from .models import CustomUser
from .forms import CustomUserCreationForm
from django.contrib.auth.admin import UserAdmin
admin.site.register(CustomUser)
@admin.register(CustomUser)
class CustomUserAdmin(admin.ModelAdmin):
add_form = CustomUserCreationForm
fieldsets = (
*UserAdmin.fieldsets,
(
'Individual data',
{
'fields': (
'custom',
'phone',
'address',
)
}
)
)

View file

@ -0,0 +1,7 @@
from django.contrib.auth.forms import UserCreationForm
from .models import CustomUser
class CustomUserCreationForm(UserCreationForm):
class Meta:
model = CustomUser
fields = '__all__'