官术网_书友最值得收藏!

Admin

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) 
 
主站蜘蛛池模板: 沾化县| 虞城县| 陕西省| 原阳县| 高青县| 海丰县| 盐边县| 江陵县| 双辽市| 堆龙德庆县| 乌鲁木齐市| 库尔勒市| 青河县| 封开县| 石林| 雅安市| 黑河市| 古田县| 闵行区| 县级市| 云和县| 遵化市| 虎林市| 黄石市| 定结县| 法库县| 潮州市| 玉龙| 铁力市| 泉州市| 江永县| 岐山县| 云浮市| 华坪县| 营山县| 尼木县| 罗甸县| 澄江县| 碌曲县| 白水县| 桃源县|