I am trying to extend the django contrib.auth user model using the built-in Profile profile to include additional fields.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
class Profile(models.Model):
user = models.ForeignKey(User, unique=True, related_name='profile')
avatar = '/images/avatar.png'
nickname = 'Renz'
class UserProfileInline(admin.StackedInline):
model = Profile
class UserProfileAdmin(UserAdmin):
inlines = (UserProfileInline,)
admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
This works fine for the "Change user" page of the administrator, but I cannot find a way to add inline model fields to list_display. Just by specifying the profile field names in the display_list, give me an error:
UserProfileAdmin.list_display [4], 'avatar' is not a callable or the attribute "UserProfileAdmin" or is not found in the "User" model.
, , , .
?