Create superuser Django in PyCharm

18,793

Solution 1

Well it looks like it is a bug in pycharm 4.3.1 and python 3.4 and django 1.7I faced the same problem and after searching for a while, I managed to solve the issue through using the command line. In the command line type:

$python manage.py createsuperuser

then it will ask you for username, type that and press enter. Notice that you might not be able to use the username you used while trying to create the superuser the first time

then enter an email

and a password and reenter the password while entering the password, you will notice it is hiding it and not moving the cursor, don't think it is not getting what you type Then you're done.

The reason why you can't use the username from first time is that Django might have created a superuser using that username but it missed up with the password or sth as the discussion from this thread suggests, however, I am not sure of that.

Solution 2

Goto : PyCharm > Tools > Run django Console >

from django.contrib.auth.models import User
User.objects.create_superuser(username='yourUsername', password='YourPassword', email='[email protected]')

Cheers !

Solution 3

Go to cmd or if you are in pycharm, go to Terminal. paste it:

python manage.py createsuperuser

Then, follow instructions in terminal. all set. Now inside terminal,paste it:

python manage.py runserver

after clicking that local server, add /admin in url. in my case:

http://127.0.0.1:8000/admin

Give your username and password,it will redirect you to Django administration page.
upvote if it works...

Share:
18,793
tryingtolearn
Author by

tryingtolearn

Updated on June 12, 2022

Comments

  • tryingtolearn
    tryingtolearn about 2 years

    I'm following the basic tutorial but for some reason any time I try to create a superuser (run manage.py Task --> createsuperuser) I get an error in the program.

    It returns "Superuser created." but after giving me this error:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: cannot import name 'setup_environ'
    

    When I try to login to 127.0.0.1:8000/admin

    I get incorrect credentials. Any thoughts?

    As of now all I have are django installed through pycharm and python 3.4 and django 1.7.

  • Edd
    Edd almost 5 years
    This worked for me because the email field was mandatory so, the accepted answer failed since it only asks for username and password.
  • Blueriver
    Blueriver over 4 years
    from django.contrib.auth.models import User is not working anymore. Instead, you can use this: from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', 'somesecurepassword')