Dr. Greenthumb
Dr. Greenthumb

Reputation: 2316

createsuperuser invalid syntax in Django

I ran into a problem while going through my first Django tutorial.

I didn't create an initial superuser account during syncdb and I'm now trying to create it programmatically. The problem is that I'm getting an invalid syntax error when I run the command:

>>> django-admin.py createsuperuser
  File "<stdin>", line 1
    django-admin.py createsuperuser
                                  ^
SyntaxError: invalid syntax

I am running Django through Python tools for Visual Studio 2010. Both 'django.contrib.auth' and 'django.contrib.admin' are enabled in settings.py. Here is the tutorial that I'm following.

Upvotes: 0

Views: 2725

Answers (2)

jacob
jacob

Reputation: 1

you are executing it from the python shell. first quit the shell with quit(), then execute in the terminal python3 manage.py createsuperuser

Upvotes: 0

karthikr
karthikr

Reputation: 99660

Looks like you are running the command in the django shell. You need to run this command in the command prompt/terminal instead.

Demo

(_env)k@dev:~/workspace/prj krav 48 $ ./manage.py shell
In [1]: manage.py createsuperuser
------------------------------------------------------------
   File "<ipython console>", line 1
     manage.py createsuperuser
                             ^
SyntaxError: invalid syntax

Continued..

In [2]: exit()
Do you really want to exit ([y]/n)? y
(_env)k@dev:~/workspace/prj krav 48 $ ./manage.py createsuperuser
Username: 

Upvotes: 2

Related Questions