Django 1.5 custom User model error. "Manager isn't available; User has been swapped"

Posted by bpetit on Stack Overflow See other posts from Stack Overflow or by bpetit
Published on 2012-11-26T15:42:05Z Indexed on 2012/11/26 17:04 UTC
Read the original article Hit count: 259

Filed under:
|
|

I extend the django user model as described in the dev doc. I wan't to keep most of the original User model features so I extend the AbstractUser class. I've defined in settings.py:

AUTH_USER_MODEL = 'myapp.CustomUser'

My user class:

class CustomUser(AbstractUser):
  custom_field = models.ForeignKey('OtherModel')
  objects = UserManager()

Everything seems to work fine but when I try to make it managed by the admin site:

admin.site.register(CustomUser, UserAdmin)

I get this error on the admin CustomUser creation page (after validation of the password confirmation form):

AttributeError: Manager isn't available; User has been swapped for 'myapp.CustomUser'

The point is that I need this model managed by the admin site in order to have the same creation process as with the original User model (two step process with password validation).

Thanks for any reply

© Stack Overflow or respective owner

Related posts about django

Related posts about django-admin