When I ran the command on CMD manage.py runserver it intern redirected to VS Code. When I tried to run on VS Code it showed the system cannot find the specified path. It was underlining this statement:
try:
from django.core.management
^^^^^^^^^^^^^^^^^^^^^^
first you need to add the python path to your variable environnement
Second
navigate to your django project and use terminal with this command :
python manage.py runserver
use Docs
I am using the command "python3 manage.py runserver_plus 0.0.0.0:9999 --cert-file /path/to/cert/app" to run my python-django project on https but I get the below error
File "/Users/xyz/django_dev_portal/django-api-1/app/manage.py", line 16
) from exc
^
SyntaxError: invalid syntax
I have django-extensions installed. Im unable to figure out whats going wrong as Im very new to Django and Python.
Any help is greatly appreciated.
Python Version : 3.7.2
Cheers,
Sheetal
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.
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 '...'):
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='your#email.com')
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
Use "Windows PowerShell" or "Windows Cmd" and then use same command. Git command interface has some restriction.
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.
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
From Django 3.0 you can do it without TTY
DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_PASSWORD=psw \
python manage.py createsuperuser --email=admin#admin.com --noinput
also, you can set DJANGO_SUPERUSER_PASSWORD as the environment variable
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
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 :
So I have a centos 6.6 on ec2.
Installed python 2.7, virtualenv for 2.7, pip-2.7 and created a virtualenv
install with my pip inside by virtualenv (2.7 all, promise) django 1.7.1
startproject works. I have my project. but:
python manage.py runserver 0.0.0.0:8080 / python manage.py migrate and everything that use manage.py gets this error:
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x1c43848>
Traceback (most recent call last):
File "/opt/webapps/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 222, in wrapper
fn(*args, **kwargs)
....
File "/opt/webapps/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
File "/opt/webapps/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 483, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: near "N": syntax error
I have no idea why this keeps happening. uninstalled & re-installed all but this error would stay anyway.
Google keeps suggesting south install / vagrant but I don't use them now.
Someone know what this thing is about?
BTW:
which python: /opt/webapps/env/bin/python
which pip: /opt/webapps/env/bin/pip
all in virtualenv in the right place and --version should 2.7
django.db.utils.OperationalError occures when validation of one of migrations failed. So, you should check all migrations of your project for incorrect SQL-syntax ("N").
I'm trying to load fixture:
python manage.py loaddata stock/fixtures/initial_data.json
But error occurred without traceback (I don't know which model is the problem):
ValueError: Problem installing fixture 'stock/fixtures/initial_data.json': The database backend does not accept 0 as a value for AutoField.
How get the traceback?
There's a --traceback option.
python manage.py loaddata stock/fixtures/initial_data.json --traceback
This isn't mentioned in the loaddata docs, it's part of the default command options.