manage.py invaild syntax error in kali server - django

I have a django project I want to publish it on an ubuntu server when I activate the virtual environment and make python manage.py runserver:
File "manage.py",line 17
)from exc
^
SyntaxError:invalid syntax
I'm getting the same error in every command about manage.py, not just the run server. I tried the makemigrations and migrate commands, it didn't work.
I activated the virtual environment, it still didn't work I deleted django and reinstalled it still didn't work

Related

Problem recovering django with pipenv after crash

I recently had a catastrophic hard drive failure and I had not pushed all of my recent commits to a remote repository (I have learned my lesson). Fortunately I did have a copy of most of my latest work.
I recreated my local environment (I thought correctly but maybe not) and attempted to start the project with the files. When I run "pipenv shell" the env appears to activate and running "git branch" does show the two branches. However when I ran "python manage.py migrate" I received the following error:
(sitefolder) user#users-MBP ohive % python manage.py migrate
File "manage.py", line 17
) from exc
^
SyntaxError: invalid syntax
When I run "python -V" it returns 2.7.18. The python version should be 3.9.6. When I do start pipenv shell in a folder without the old files, the correct version is returned.
Any ideas about how I can get the pipenv to use the correct version of python?
I recreated my local environment (I thought correctly but maybe not) and attempted to start the project with the files.
You probably made a virtual environment with python-2.x as interpreter, you can construct one with:
pipenv --python 3

Django on Heroku - ProgrammingError at / relation "..." does not exist

I'm getting this error. I know you usually get this error because the databases wasn't properly migrated.
When I run heroku local web, the website works fine when I go to localhost:5000.
However after I deploy the app to heroku with git push heroku master, the error comes up.
In other words, it works in my local environment. But it does not work after deploying to heroku.
I have Heroku-Postgres installed as an add-on in heroku.
What could be causing this?
excute migrations and makemigrations in bash heroku. open the terminal in the local project folder and give the following commands:
heroku run bash
~$ ./manage.py makemigrations
~$ ./manage.py migrate
~$ exit
The following steps did it for me
Make all the necessary migrations (python manage.py makemigrations) and migrate (python manage.py migrate) locally,
push to heroku master
and finally running heroku run python manage.py migrate
Solved the issue
I experienced the same error after making a change to a model and then deploying this change to heroku.
The only way I managed to fix this problem was to do the following:
Reset the database in heroku
Delete the migrations files from the migrations folder for the broken app locally (but keep the directory and the __init__.py file)
Run python manage.py makemigrations and python manage.py migrate. This will repopulate the migrations folder with clean migration files.
Push changes to master (ensure that you do not have migrations directories in .gitignore files.
Deploy changes to heroku
Run the heroku shell heroku run bash
Run python manage.py migrate
I was able to do this because my tables did not have much data in, but I would try to avoid resetting the database if I had more data in my tables.

Django 1.9 ImportError when running migrate, but not runserver

I'm trying to run a new migration on a new Django 1.9 project but I'm getting an ImportError that seems to conflict with runserver. I'm running these commands from the <project> directory which includes the manage.py file.
Details:
Django 1.9
Using cookiecutter-django
runserver references the settings file
migrate produces an import error
In my local .env file, I have DJANGO_SETTINGS_MODULE=config.settings.local
Settings are in <project>/config/settings/...
I am running the project from within a virtualenv
Commands & Error:
$ django-admin.py migrate --settings=config.settings.local
.....
ImportError: No module named config.settings.local
$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
January 09, 2016 - 13:33:32
Django version 1.9, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Any ideas? Thanks in advance!
Use manage.py instead of django-admin.py
python manage.py migrate --settings=config.settings.local

"heroku run python manage.py collectstatic --noinput" returns "no module named haystack"

Locally, haystack is working fine when I open the project in my server.
Issues arise when I try to push to heroku. I get a collectstatic configuration error. When I try to debug using heroku run python manage.py collectstatic --noinput I get this message ImportError: No module named haystack.
In my virtualenv, Django-haystack in installed
Locally, haystack works.
I have no items yet inside my staticfiles folder/directory.
Previously, I had a Template does not exist error. My virtualenv is named the same as my project so django only entered in 2 files instead of the 3. Could the error here be similar?
Thanks to anyone willing to help.

PTVS Django Data Base Migration

Im testing Python Tools For Visual Studio, I create a django project, make a SyncDB and install django admin with no problems, but now Im trying to make Data Base migration like: Django 1.7 Migrations. the point is that i cant figuer out how to do that. I serched in google and find this: How to run django database migrations with PTVS?. So the migration command is not wraped. I tried using Windows Command Prompt and install C:\Python34\;C:\Python34\Scripts; PATHS but when i type a django command like python manage.py runserver appears No module named 'django'. It seems that i am not pointing to my django project virtual env, but i dont know how to do that.
Execute command in my django app env path does not work neither.
Image:
Thanks a lot!
Before using of virtual env you should activate it. Execute env\activate or env\bin\activate. Not a windows guy so I'm not sure which path virtualenv uses on Windows :-)
You have to activate virtualenv. Go to env/Scripts directory and run activate.bat. Then go to your main project directory and try again python manage.py runserver. If you still see No module named 'django' make sure that django is installed in this environment try pip install django.