[Django]-Can't login to django admin account after creating super user

1πŸ‘

βœ…

Did you run python manage.py migrate before you ran python manage.py createsuperuser?
During createsuperuser process, you need the username and password, you don’t need anything else, i.e. email.

You should do this first, then run python manage.py runserver

lastly, navigate to http://127.0.0.1:8000/admin/

There really isn’t anything else you would need to do. If you are getting another error, please post it.

πŸ‘€ja408

3πŸ‘

Go to the python shell:

python manage.py shell

In the python console, run the following:

from django.contrib.auth.models import User

user = User.objects.get(username='your_username') # enter inside the quotes the username you entered when you ran python manage.py createsuperuser
user.set_password('new_password') # change the password 
user.is_superuser = True
user.is_staff = True
user.save()

exit()

Then try to login again using the credentials you set.

πŸ‘€Victor

0πŸ‘

I had similar problems too but by doing as follows it worked fine.

def create_superuser(self, username, email, password=None, **extra_fields):
    user = self.create_user(username, email, password=password, is_staff=True, **extra_fields)
    user.is_active = True
    user.save(using=self._db)
    return
πŸ‘€Vkash Poudel

Leave a comment