简体   繁体   中英

Create superuser Django in PyCharm

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.

Well it looks like it is a bug in pycharm 4.3.1 and python 3.4 and django 1.7 I 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.

Goto : PyCharm > Tools > Run django Console >

from django.contrib.auth.models import User
User.objects.create_superuser(username='yourUsername', password='YourPassword', email='your@email.PK')

Cheers !

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...

Go to Terminal .Paste it:

python manage.py createsuperuser

And Then Fill your details like Username, Email and Password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM