Unable to create superuser in django due to not working in TTY
Asked Answered
S

9

9

I go through first django tutorial from djangoproject.com and at the very beginning of part 2, which is creating superuser when I run "python manage.py createsuperuser" I get the following message back:

Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually.    

I get the same message when I go on to create superuser after running syncdb.

I am working on Eclipse for Windows 7, and Django 1.7.1 together with Python 2.7.8.

Subarid answered 17/11, 2014 at 19:6 Comment(4)
How is python manage.py createsuperuser being run? Is it being run from Eclipse somehow or via the windows command line?Overhang
From eclipse custom command tool for Django projects.Subarid
Could we try running 'python manage.py createsuperuser' from the windows command line instead of the eclipse custom command tool?Overhang
Wow, I feel like an idiot for not trying this myself. Worked like a charm, thanks Kevin.Subarid
B
21

When using the Git Bash and to correct the above error message try to append winpty
i.e. for example:

$ winpty python manage.py createsuperuser
Username (leave blank to use '...'):
Barna answered 25/8, 2017 at 8:11 Comment(2)
What does wintpy do?Heerlen
@Heerlen winpty is a Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programsBarna
G
5

You can create a superuser using django shell (python manage.py shell)

from django.contrib.auth.models import User
User.objects.create_superuser(username='YourUsername', password='hunter2', email='[email protected]')
Guacharo answered 4/2, 2018 at 0:6 Comment(1)
It's helpful, but it fights against consequences not reasons.Disregardful
O
4

if you are in virtualenv, cd into your virtualenv and activate it. then try these steps:

python manage.py syncdb --noinput
python manage.py migrate
python manage.py createsuperuser
Olcott answered 17/11, 2014 at 19:15 Comment(4)
I installed django from windows command line without using virtualenv or any other installation managing programs. Is there a way around my problem without installing more stuff? Besides, would it help if I got them now?Subarid
@Subarid did you run these 3 commands? you dont need to install aynthing to get this to workOlcott
Yes I did, still the same message.Subarid
Use the commandline tool instead of the custom command in eclipseSolita
Y
1

I am a Windows10 user. I tried to run py manage.py createsuperuser command using Git Bash console, but error has been thrown. Then I switched Git Bash to native Windows Command Line with administrator privileges, and re-run command - it was working.

Yehudi answered 25/10, 2016 at 15:1 Comment(0)
A
1

Use "Windows PowerShell" or "Windows Cmd" and then use same command. Git command interface has some restriction.

Advisement answered 21/11, 2016 at 7:3 Comment(0)
K
0

First run

$ django-admin startproject mysite 

in cmd prompt, then apply migration by

cd mysite
mysite:

python manage.py makemigrations

then

python manage.py migrate

after that

python manage.py createsuperuser
Keil answered 17/5, 2019 at 8:4 Comment(0)
F
0

From Django 3.0 you can do it without TTY

    DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_PASSWORD=psw \
    python manage.py createsuperuser [email protected] --noinput

also, you can set DJANGO_SUPERUSER_PASSWORD as the environment variable

Fabrizio answered 5/1, 2022 at 13:12 Comment(0)
S
0

If you are Windows user using GitBash terminal and trying to create super for admin it won't work instead of that use command prompt in administrative privilege it works

Gitbash terminal error

$ python manage.py createsuperuser
Superuser creation skipped due to not running in a TTY. You can run "manage.py createsuperuser" in your project to create one manually.

Error Resolved Using Command Prompt

python manage.py createsuperuser
Username (leave blank to use 'user'): admin
Email address:
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

This might be helpful for others. Do Upvote for this if it works for you

Strapping answered 8/2, 2022 at 12:42 Comment(0)
E
-1

Use this command :

python3 manage.py makemigrations

python3 manage.py migrate

python3 manage.py createsuperuser

python manage.py runserver

Your error is probably:

[Error `You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, content types, sessions.
Run 'python manage.py migrate' to apply them.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 303, in execute
    return Database.Cursor.execute(self, query, params)`][1]

check you yo directory with Tree command:tree

Then run Make migration : enter image description here

then create superuser with the python3 manage.py createsuperusercommand :

Equerry answered 3/12, 2019 at 11:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.