django project not executing makemigrations command as expected in vscode editör - django

I have a django project. I moved my project from pyCharm editor to vscode editor. When I run the python manage.py makemigrations command, it creates a migration file for some applications under venv. I think it depends on the LANGUAGE_CODE value in settings.py but I used gettext_lazy in all my models. Even if I type the command python manage.py makemigrations app_label, it still creates migration files for projects under venv. The libraries installed with pip install under venv are my own django projects. I have always used gettext_lazy in these projects. Same projects execute makemigrations in pyCharm editor with no issues

Related

Django.db.utils.ProgramingError Relation doesn't exist

I am using Django3 and Postgres as Database, I clone the old project using Django and postgres, I cloned and setup the virtual environment for my project.
At the time of runserver, its throws me the error of
Django.db.utils.ProgramingError realtion "Table name" doesn't exist
There was the migrations file in the project when I cloned it, but I removed them, so can create my own, but this error still there, even I remove the migrations folder, but its still there and can't create my own migrations and not even start the server.
I tried it with cloned migrations files and without it but can't runserver
Run this command python manage.py showmigrations
Remove the actual migration files
Go through each of your projects apps migration folder and remove
everything inside, except for the init.py file
Then run python manage.py makemigrations

What's the proper way to run a south schemamigration in a Django package?

I'm working with a third-party Django package, and I'm not sure how to create a schemamigration. What's the equivalent of:
./manage.py schemamigration <app_name> when I don't have a ./manage.py?
While I don't think we can create South migrations without build a real django site(btw, you also need the django site for testing). Just treat your package like other django packages, and run schemamigration <your_app_name> to create migrations for it.
You only need to let django store migrations under your package's migrations directory instead of 'env/lib/pythonXX/site-packages/' You need to install your app with pip's editable” mode.
pip install -e local_path/to/your_package

Pinax on Webfaction - manage.py syncdb not finding virtualenv

(pinax09)[user#web213 social]$ python manage.py syncdb
Error: Can't import Pinax. Make sure you are in a virtual environment that has
Pinax installed or create one with pinax-boot.py.
I'm obviously in pinax09 virtualenv which has pinax installed hence I could create a social project with setup_project. However, once I run the syncdb it complains it can't import Pinax. What could be the problem?
Might be a problem with Python versions - I've had that on Webfaction before. Try just ./manage.py syncdb, without the python, which should run the correct version.

Adding South to Django project, development & production

Adding South to an existing Django project. I have it installed on both the development machine and the "production" server.
I've done the following on the development machine, then: added South app to settings.py,
python manage.py syncdb
python manage.py convert_to_south myproject.myapp
then changed some models, then
python manage.py schemamigration myproject.myapp --auto
python manage.py migrate myproject.myapp
Seems to work so far. What I am now not so sure about is what to do on the production server. Just repeat all these steps manually? Upload modified settings.py, do syncdb, convert_to_south, upload modified models.py, do schemamigration, migrate? Something different? The tutorial here says something about adding migrations to the version control, so, presumably, they should be uploaded and somehow applied on the production server?
Furthermore, right now I am using sqlite3 on the development machine and mysql on the server - does it make things any different south-wise?
My guide says:
Install South on server. import south from shell just to make sure you are using the same python env.
Add 'south' to INSTALLED_APPS in settings.py.
Upload settings.py.
Restart server
python manage.py syncdb.
Upload new app/models.py and app/migrations/ dir.
Restart server.
python manage.py migrate app --fake 0001
python manage.py migrate app
To make sure the south migration table exists,
python manage.py syncdb
and then
python manage.py migrate myproject.myapp --fake 0001
python manage.py migrate myproject.myapp
That's what's worked for me. :)
No need to do this in Django >= 1.7
i am stuck on this more then 1 hour :)
and at last find 1.7 and more have in build upgrading-from-south
for more info https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south
may be this one help you

Django not finding apps in virtualenv when using manage.py syncdb

My problem is in getting manage.py syncdb to run within a virtualenv.
It was working fine at one point, but seems to have broken sometime around when I installed South and updated pip and distribute.
Anyways, when the virtualenv is activated, I can import apps fine within the interactive interpreter. Running through mod_wsgi, the apps are imported as well, and the site can run.
When I run manage.py syncdb, it fails to find any app in INSTALLED_APPS that is in my virtualenv. It picks up system-installed apps fine, but fails when it tries to import virtualenv only apps.
Hi This is an old question, but saw its not answered. Not sure what you are attempting to do, but there are basically two modes you can use virtualenv,
For development, to create self-contained environments
For deployment, to create self-contained environments
In the first case, you need to first Activate your virtualenv with source venv/bin/activate, for when you deploy, you need to ensure that the virtualenv is activated for your website code. Personally i prefer the following approach to ensuring your path is set correctly. (I also add this to my manage.py when doing development, so i dont have to worry about activating the environment first.
Modified manage.py
#!/usr/bin/env python
import os.path
# Cater for Virtual env, add to sys.path
pwd = os.path.abspath(os.path.dirname(__file__))
project = os.path.basename(pwd)
new_path = pwd.strip(project)
activate_this = os.path.join(new_path,'venv','bin','activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)
This works, due to how i structure my projects, you would have to change it to your directory structure. My projects are structured like so:
TopLevelDir
|
|- Project DIR
|- venv
|- requirements
|- deployment configs
I have a simple solution to this
Just launch manage.py from the python in the bin of your virtual environment.
So say your python is here /home/tom/environments/my_env/bin/python you could launch manage.py like so:
/home/tom/environments/my_env/bin/python manage.py syncdb
then just create a symlink to the virtual environment's python inside your django project and call it env_python then you can do this:
./env_python manage.py syncdb