Django admin panel doesn't work after modify default user model.

Posted by damienix on Stack Overflow See other posts from Stack Overflow or by damienix
Published on 2011-01-08T13:44:27Z Indexed on 2011/01/08 13:54 UTC
Read the original article Hit count: 152

Filed under:
|
|
|

I was trying to extend user profile. I founded a few solutions, but the most recommended was to create new user class containing foreign key to original django.contrib.auth.models.User class. I did it with this so i have in models.py:

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    website_url = models.URLField(verify_exists=False)

and in my admin.py

from django.contrib import admin
from someapp.models import *
from django.contrib.auth.admin import UserAdmin

# Define an inline admin descriptor for UserProfile model
class UserProfileInline(admin.TabularInline):
    model = UserProfile
    fk_name = 'user'
    max_num = 1

# Define a new UserAdmin class
class MyUserAdmin(UserAdmin):
    inlines = [UserProfileInline, ]

# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)

And now when I'm trying to create/edit user in admin panel i have an error: "Unknown column 'content_userprofile.id' in 'field list'" where content is my appname.

I was trying to add line AUTH_PROFILE_MODULE = 'content.UserProfile' to my settings.py but with no effect.

How to tell panel admin to know how to correctly display fields in user form?

© Stack Overflow or respective owner

Related posts about python

Related posts about django