Trying to create a super user for my database:
manage.py createsuperuser
Getting a sad recursive message:
Superuser creation skipped due to not running in a TTY. You can run manage.py createsuperuser
in your project to create one manually.
Seriously Django? Seriously?
The only information I found for this was the one listed above but it didn’t work:
Unable to create superuser in django due to not working in TTY
And this other one here, which is basically the same:
Can’t Create Super User Django
asked Sep 11, 2015 at 22:15
6
If you run
$ 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.
from Git Bash and face the above error message try to append winpty
i.e. for example:
$ winpty python manage.py createsuperuser Username (leave blank to use '...'):
To be able to run python
commands as usual on windows as well what I normally do is appending an alias line to the ~/.profile
file i.e.
MINGW64 ~$ cat ~/.profile
alias python='winpty python'
After doing so, either source the ~/.profile
file or simply restart the terminal and the initial command python manage.py createsuperuser
should work as expected!
answered May 7, 2016 at 20:55
Evgeny BobkinEvgeny Bobkin
4,0622 gold badges17 silver badges21 bronze badges
3
In virtualenv, for creating super-user for Django project related to git-bash use the command:
winpty python manage.py createsuperuser.
jcaliz
3,8712 gold badges8 silver badges13 bronze badges
answered Apr 13, 2020 at 3:12
1
I had same problem when trying to create superuser in the docker container with command:
sudo docker exec -i <container_name> sh
. Adding option -t solved the problem:
sudo docker exec -it <container_name> sh
answered Apr 13, 2019 at 12:29
markemarke
1,0247 silver badges20 bronze badges
Since Django 3.0 you can create a superuser without TTY in two ways
Way 1: Pass values and secrets as ENV in the command line
DJANGO_SUPERUSER_USERNAME=admin2 DJANGO_SUPERUSER_PASSWORD=psw
python manage.py createsuperuser --email=admin@admin.com --noinput
Way 2: set DJANGO_SUPERUSER_PASSWORD as the environment variable
# .admin.env
DJANGO_SUPERUSER_PASSWORD=psw
# bash
source '.admin.env' && python manage.py createsuperuser --username=admin --email=admin@admin.com --noinput
The output should say: Superuser created successfully.
answered Jan 5, 2022 at 13:09
pymenpymen
5,53743 silver badges35 bronze badges
To create an admin username and password, you must first use the command:
python manage.py migrate
Then after use the command:
python manage.py createsuperuser
Once these steps are complete, the program will ask you to enter:
- username
- password
With the password, it will not show as you are typing so it will appear as though you are not typing, but ignore it as it will ask you to renter the password.
When you complete these steps, use the command:
python manage.py runserver
In the browser add «/admin», which will take you to the admin site, and then type in your new username and password.
answered Nov 15, 2019 at 18:02
darrelldarrell
531 silver badge4 bronze badges
Check your docker-compose.yml file and make sure your django application is labeled by web under services.
answered Nov 12, 2021 at 8:04
EILYAEILYA
3374 silver badges5 bronze badges
I tried creating superuser from Stash [ App: Pythonista on iOS ]
[ Make sure migrations are already made ]
$ django-admin createsuperuser
answered Nov 20, 2020 at 5:12
I figured out how to do so. What I did was I went to VIEWS.py. Next, I imported the module os
. Then I created a function called createSuperUser(request):
. Then, I then created a variable called admin
and set it equal to os.system("python manage.py createsuperuser")
. Then after that, return admin
. Finally, I restarted the Django site, then it will prompt you in the terminal.
import os
def createSuperUser(request):
admin = os.system("python manage.py createsuperuser")
return
Gino Mempin
24.5k28 gold badges92 silver badges128 bronze badges
answered Nov 20, 2019 at 22:38
darrelldarrell
531 silver badge4 bronze badges
Hi @zippo-lighter ,
I have tried to reproduce your bug with no luck. I’ve been able to create the super user, both in linux and Windows 10 (using Docker Desktop).
Have you tried to do what is suggested in your screenshot?. Instead of executing taiga-manage.sh
from the machine that hosts the docker containers, try to start and run the python script by connecting to the taiga-back
running container:
PS H:TEMPtaiga-docker-stable> docker exec -it taiga-docker-stable_taiga-back_1 bash
root@921f7f92d4e9:/taiga-back# python manage.py createsuperuser
Username: taiga
Email address: superuser@domain.com
Password:
Password (again):
Superuser created successfully.
If that doesn’t either fix the problem, I would need further information, like:
- What are the logs you get executing python manage.py directly?
- Do you see something in the docker-compose logs?
- Can you share your docker-compose.yml?
Thanks in advance
Django
February 18, 2021
1 Minute
Error
When I tried to run this command: python manage.py createsuperuser
in my Django project, it gave me a super long error which included the following:
File “manage.py”, line 22, in
main()
File “manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/core/management/init.py”, line 364, in execute_from_command_line
utility.execute()
….
ImportError: cannot import name ‘path’ from ‘django.urls’ (/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/urls/init.py)
Solution
The problem in my case was that I had the wrong version of Django installed. In order to run the python manage.py createsuperuser
command you need at least Django 2.
Run this command to check the version of Django you are currently working with:
python -m django --version
Run this command to install the latest version of Django.
pip install --upgrade django
Run the python -m django --version
command again and make sure your new Django version is 2.x or above. If so, you should be able to run python manage.py createsuperuser
now
Published
February 18, 2021
I am trying to create a superuser through createsuperuser command in manage.py console is throwing an error «No Django settings specified. Also tried in python console by runninf python manage.py createsuperuser
Unknown command: ‘createsuperuser’
Type ‘manage.py help’ for usage.»
I AM USING PYCHARM
settings.py
"""
Django settings for MovieFlix project.
Generated by 'django-admin startproject' using Django 4.0.2.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-#*8cdy*ul906(s4ei#g7h17)vv%)#0s5b##weupzn-&ct@ylez'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['192.168.2.12', '127.0.0.1']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Core.apps.CoreConfig',
'movie.apps.MovieConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'MovieFlix.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'Core/templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'MovieFlix.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
# 'default': {
# 'ENGINE': 'djongo',
# 'NAME': 'MovieFlix',
# 'ENFORCE_SCHEMA': False,
# 'CLIENT': {
# 'host': 'mongodb+srv://movieflix:movieflix%401234@cluster0.fm15x.mongodb.net/MovieFlix?retryWrites=true&w=majority'
# }
# }
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
manage.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MovieFlix.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Использую python 3.5 и django 1.9.4. написал в терминале:
python manage.py migrate
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.
Понял в чем проблема хотел решить таким способом:
python manage.py syncdb --noinput
python manage.py migrate
python manage.py createsuperuser
но после того как пишу я это:python manage.py syncdb --noinput
мне выдает это:
Unknown command: 'syncdb'
Type 'manage.py help' for usage.
Что делать в таком случаи?)