May 2018
Beginner to intermediate
282 pages
7h 58m
English
Now, a user's details will be in two different places within the admin: the authentication details in the usual user admin page, and the same user's additional profile details in a separate profile admin page. This gets very cumbersome.
For convenience, the profile admin can be made inline to the default user admin by defining a custom UserAdmin in profiles/admin.py as follows:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import Profile
from django.contrib.auth.models import User
class UserProfileInline(admin.StackedInline):
model = Profile
class NewUserAdmin(UserAdmin):
inlines = [UserProfileInline]
admin.site.unregister(User)
admin.site.register(User, NewUserAdmin)
Read now
Unlock full access