3👍
You may use Model Inheritance for that, which do similar things for you…
2👍
Have you tried to use a simple inline for the profile? Yes, it will be shown at the bottom, but otherwise it would work.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from website.users.models import UserProfile
admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model = UserProfile
max_num = 1
class UserProfileAdmin(UserAdmin):
inlines = [UserProfileInline]
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'email', 'password1', 'password2')}
),
)
fieldsets = (
(None, {'fields': ('username', 'password')}),
(('Personal info'), {'fields': ('first_name', 'last_name', 'email', 'location')}),
(('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),
(('Important dates'), {'fields': ('last_login', 'date_joined')}),
(('Groups'), {'fields': ('groups',)}),
)
admin.site.register(User, UserProfileAdmin)
- [Django]-Django changing rendered url in a view
- [Django]-Docker build network error when trying to pip install
- [Django]-Validate object attribute in manager in Django
- [Django]-What is the use of "user = self.model(useremail=BmUserManager.normalize_email(useremail))" ? is it used to create a new custom user?
Source:stackexchange.com