Search code examples
pythondjangoauthenticationadminregistration

Django custom User not registering with Admin


I've followed the documentation at https://docs.djangoproject.com/en/2.0/topics/auth/customizing/#substituting-a-custom-user-model, but for some reason things still aren't working for me. I can create and login to User accounts, but for some reason I can't view them with the admin. This leads me to believe they're not being registered correctly, but as said before, I've followed the documentation on how to do that:

sign_up/models.py

from django.contrib.auth.models import AbstractUser


# Create your models here.
class User(AbstractUser):
    pass

sign_up/admin.py

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from .models import User

# Register your models here.
admin.register(User, UserAdmin)

site/settings.py

# define custom user model
AUTH_USER_MODEL = 'sign_up.User'

I've also tried deleting my database and migrations and reapplying them, but this still isn't helping.


Solution

  • not this

    admin.register(User, UserAdmin)
    

    but this

    admin.site.register(User, UserAdmin)