[Fixed]-Can't login to django admin after creating a super user with a custom user model

15👍

The code is fine. The problem is you’re using the RemoteUserBackend exclusively, instead of the default backend:

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.RemoteUserBackend',
)

I’ve never used it myself, but from the docs it’s clear that it’ll only check for a REMOTE_USER header in your requests, thus making your password login attempts irrelevant.

You could add the default ModelBackend as a fallback, if you wan’t to have both available:

AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.RemoteUserBackend',
        'django.contrib.auth.backends.ModelBackend',
)

or get rid of the RemoteUserBackend alltogether and have your app authenticate the default way.

Hope this helps.

6👍

Maybe you could also try to set in the create_superuser

user.is_active = True

1👍

Make sure you Super User is associated to one of the profiles you have created, maybe by iserting it manually intro you DB.

Take care

Leave a comment