4

I'm trying to register a custom User Admin with a memberprofile inline. Based on SO answers and google my admin.py looks like:

class MemberProfileInline(admin.StackedInline):
    model = MemberProfile
    fk_name = 'user'


class FSUserAdmin(UserAdmin):
    list_display = ('id', 'username',)
    inlines = [MemberProfileInline,]

admin.site.unregister(User)
admin.site.register(User, FSUserAdmin)

When I load up the admin, none of the changes defined in FSUserAdmin take place. If I comment out

admin.site.register(User, FSUserAdmin)

I get the error that the user site is not registered, so i know it is getting unregistered successfully.

Does anyone have any insight into what I'm missing?

update: django.contrib.auth and django.contrib.admin appear before any project specific apps in the INSTALLED_APPS list in settings.py

I've got the following in my project urls.py

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
arulmr
  • 8,620
  • 9
  • 54
  • 69
w--
  • 6,427
  • 12
  • 54
  • 92
  • Have you tried the answer here? http://stackoverflow.com/questions/2270537/how-to-customize-the-auth-user-admin-page-in-django-crud – Josh Smeaton Dec 04 '12 at 12:08
  • do you mean the comment from @JamieForrest of adding it to the site's top level admin.py file? – w-- Dec 05 '12 at 00:36

1 Answers1

0

Make sure that this app appears below contrib.auth in your INSTALLED_APPS setting.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • all the django contrib apps appear before any of my project specific apps. I didn't bother to post that because i assume if it didn't the call to unregister wouldnt do anything. – w-- Jun 13 '12 at 20:52
  • 2
    My other suggestion is to make sure you've got [`admin.autodiscover()`](https://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf) in your urls.py. If you're manually importing the admin modules instead, then perhaps the user admin is not being registered, so there's no need to unregister it! Hope you get it working. – Alasdair Jun 13 '12 at 22:22
  • yes, in the root urls.py i have admin.autodiscover() and i'm not manually importing the admin modules =\. thanks for your suggestions. – w-- Jun 13 '12 at 23:44