tryingtolearn
tryingtolearn

Reputation: 2646

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.

Upvotes: 13

Views: 20459

Answers (3)

Abdullah Al Masum
Abdullah Al Masum

Reputation: 51

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

Upvotes: 1

Saad Bin Shahid
Saad Bin Shahid

Reputation: 344

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 !

Upvotes: 14

A_Matar
A_Matar

Reputation: 2330

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.

Upvotes: 15

Related Questions