Unable to use runserver_plus for django - python

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

Related

Mac OS Django-admin startproject mysite receives syntax error

I'm trying to follow the tutorial on https://docs.djangoproject.com/en/3.1/intro/tutorial01/ and have made it to the step where you are supposed to run django-admin startproject mysite in the command line.
I have tried running the followings:
django-admin startproject mysite
django-admin.py startproject mysite
django-admin startproject.py mysite
$ django-admin startproject mysite
and
$ django-admin.py startproject mysite
and all of them receive
SyntaxError: invalid syntax
either with a ^ under the "t" in "startproject" or under the $ when I've tried that.
I've searched through about ten different posts trying to figure out how to proceed, and none of the answers provided have worked for me. They all continue to receive
SyntaxError: invalid syntax
I would really appreciate any insight into why this is happening and how to fix it.
What did you get as a response when you typed python -m django --version in terminal?
Given that you have django installed properly, django-admin startproject *name of project* is the correct syntax. (the first line you listed is correct).
Perhaps try to re-install django and try again. You can access the docs for installing here

sqlite3 works well in centos7 and python shell,but can't work in Uwsgi

I have a question need your help~
I have a django program run in a vps(centos7,django2.2),it works well with Nginx+Uwsgi.
I edit three files(like a.py b.py c.py),and upload to the vps by winscp.exe,the program can't work now.
I found these logs in the uwsgi.log file.
File "/mnt/datasource/<privacy_hidden>/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 68, in <module>
check_sqlite_version()
File "/mnt/datasource/<privacy_hidden>/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 65, in check_sqlite_version
raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
unable to load app 0 (mountpoint='') (callable not found or import error)
I wrote "sqlite3 --version" in centos7 shell, it show version = 3.30.1
I wrote "python >>> import sqlite3 >>>print sqlite3.sqlite_version" it show version=3.30.1
I wrote "python manage.py runserver --noreload 0.0.0.0:80",it works well, no info show sqlite error.
But the program can't work in uwsgi,I think the uwsgi.ini is correct.
What can I do ?
Thank you!
I think I have solved this question.
In centos shell:
> mv /usr/lib64/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6_old
> cp /usr/local/lib/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6
then it's ok
uwsgi has RPATH set. and its' /usr/lib64, and the old sqlite library is in this directory, you need to use the newer sqlite library in /usr/local/lib.
you could recompile uwsgi like this: sudo LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib" pip3 install uwsgi.
refrence: https://sourceexample.com/en/1c4153d4c3d4e65dac45/

Django command "django-admin startmyproject" not working?

The above mentioned command is not working.
Showing the result after giving command -
No Django settings specified.
Unknown command: 'startmyproject'. Did you mean startproject?
Type 'django-admin help' for usage.
Unknown command: 'startmyproject'. Did you mean startproject?
The result is pretty self-explanatory, no such command exist. It's django-admin startproject
https://docs.djangoproject.com/en/dev/ref/django-admin/#startproject
Your command should be startproject. Also, have u defined a django settings file for ur django installation. Try out the steps in this documentation to make this work correctly.
https://docs.djangoproject.com/en/2.1/topics/settings/
I think you need to run this django-admin startproject 'your peoject name goes here'
This should be just after activating virtual and installing django

Getting error when trying to migrate in django

Hey I'm trying to migrate my project using the command python manage.py makemigrations in django and I keep getting this error:
File "manage.py", line 14
) from exc
^
SyntaxError: invalid syntax
I have already found similar answers on it but nothing has worked. I am currently in the virtual environment already and changing the command to python3 manage.py makemigrations also prompts the same error.
The raise-from statement, or exception chaining, is only supported since Python 3.
Please upgrade your Python version to 3.0 or above in order to run this manage.py.

Running python LAMPP (linux) via apache

I have a file: test.py
Permissions on this file are set to 777, I am attempting to run the following script:
#!/usr/lib/python2.7
print("Content-Type: text/html\n")
print("test")
I receive the following error:
The server encountered an internal error and was unable to complete your request.
Error message:
End of script output before headers: test.py
If you think this is a server error, please contact the webmaster.
Error 500
Python is installed:
$ python --version
>> Python 2.7.4
Solved the problem, you need to use the location of the python interpreter in the first line of the code which can be found by running the following script in the python interpreter (can be invoked by typing python into the terminal):
import sys; sys.executable;

Categories

Resources