169π
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!
18π
In virtualenv, for creating super-user for Django project related to git-bash use the command:
winpty python manage.py createsuperuser.
- [Django]-Does SQLAlchemy have an equivalent of Django's get_or_create?
- [Django]-Django fix Admin plural
- [Django]-Django character set with MySQL weirdness
15π
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
- [Django]-Writing a __init__ function to be used in django model
- [Django]-Setting DEBUG = False causes 500 Error
- [Django]-Django: best practice way to get model from an instance of that model
8π
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.
- [Django]-Django: Reference to an outer query may only be used in a subquery
- [Django]-Django py.test does not find settings module
- [Django]-Django-allauth: Linking multiple social accounts to a single user
4π
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.
- [Django]-'staticfiles' is not a valid tag library: Template library staticfiles not found
- [Django]-Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb
- [Django]-Django form: what is the best way to modify posted data before validating?
1π
Check your docker-compose.yml file and make sure your django application is labeled by web under services.
- [Django]-How do I integrate Ajax with Django applications?
- [Django]-Loading initial data with Django 1.7+ and data migrations
- [Django]-Manage.py runserver
0π
I tried creating superuser from Stash [ App: Pythonista on iOS ]
[ Make sure migrations are already made ]
$ django-admin createsuperuser
- [Django]-How to have a Python script for a Django app that accesses models without using the manage.py shell?
- [Django]-Django: "projects" vs "apps"
- [Django]-Can a dictionary be passed to django models on create?
-3π
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
- [Django]-How do I raise a Response Forbidden in django
- [Django]-How to get Django and ReactJS to work together?
- [Django]-Count() vs len() on a Django QuerySet