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,1022 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,8912 gold badges9 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,0248 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,74744 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
631 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
3684 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
25.6k29 gold badges98 silver badges138 bronze badges
answered Nov 20, 2019 at 22:38
darrelldarrell
631 silver badge4 bronze badges
Попытка создать суперпользователя для моей базы данных:
manage.py createsuperuser
Получение грустного рекурсивного сообщения:
Создание суперпользователя пропущено из-за отсутствия работы в TTY. Вы можете запустить manage.py createsuperuser
в своем проекте, чтобы создать его вручную.
Серьезно Django? Серьезно?
Единственная информация, которую я нашел для этого, была приведена выше, но она не работала:
Невозможно создать суперпользователя в django из-за отсутствия работы в TTY
И этот другой здесь, который в основном тот же:
Невозможно создать суперпользователя Django
Ответ 1
Если вы запустите
$ 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.
из Git Bash и обратитесь к приведенному выше сообщению об ошибке, попробуйте добавить winpty
i.e, например:
$ winpty python manage.py createsuperuser Username (leave blank to use '...'):
Чтобы иметь возможность запускать команды python
, как обычно, в Windows, а также то, что я обычно делаю, это добавить строку псевдонима в файл ~/.profile
i.e.
MINGW64 ~$ cat ~/.profile
alias python='winpty python'
После этого либо отправьте файл ~/.profile
, либо просто перезапустите терминал, а начальная команда python manage.py createsuperuser
должна работать как ожидалось!
Ответ 2
Я собираюсь предположить, что если вы используете manage.py createsuperuser
, а не python manage.py createsuperuser
, вы используете команду из среды IDE или какой-либо другой странной среды. Попробуйте запустить python manage.py createsuperuser
вне вашей среды разработки, и он должен работать. В идеале вы бы использовали виртуальную среду или virtualenvwrapper.
Ответ 3
У меня была такая же проблема при попытке создать суперпользователя в контейнере докера с помощью команды: sudo docker exec -i <container_name> sh
. Добавление опции -t решило проблему:
sudo docker exec -it <container_name> sh
Django
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
Я пытаюсь создать суперпользователя, чтобы получить доступ к инфраструктуре администратора Django в моем приложении. Я использую Vagrant на машине Windows 8.1:
> ./manage.py createsuperuser
Однако я получаю следующую ошибку:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, i
n execute_from_command_line
utility.execute()
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, i
n execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in ru
n_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in ex
ecute
output = self.handle(*args, **options)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsu
peruser.py", line 141, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/vagrant/myapp/accounts/managers.py", line 52, in create_superuser
return self._create_user(email, password, True, True, **extra_fields)
File "/vagrant/myapp/accounts/managers.py", line 31, in _create_user
user.set_slug()
File "/vagrant/myapp/accounts/models.py", line 164, in set_slug
slug = slugify(self.username, max_length=50).lower()
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/slugify/main.py", line 101, in slugify
text = join_words(words, separator, max_length)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/slugify/main.py", line 78, in join_words
text = next(words) # text = words.pop(0)
StopIteration
Я читал в другом месте (здесь) и (здесь), что это проблема «локали», но я понимаю, что это ошибка OSX, и я нахожусь в бродяжной виртуальной машине…?
Issue
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
Solution
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 By — Evgeny Bobkin