Django - syncdb causes error: "DatabaseError: no such table: django_site" - python

I recently built a dev machine to use at home, I've been spending the last couple nights trying to get it running with a development version of our website.
1] First off cloned the repo of our website into a local folder.
2] Then I created a virtualenv using virtualenvwrapper for the website
3] I then used the requirements.txt in the repo to install dependencies, this failed a ton of times and I ended up having to go through the requirements.txt one line at a time until I found out i needed mercurial installed for it to finish.
4] After verifying my dependencies were all installed I went to sync the db with "python manage.py syncdb" and got the error: "DatabaseError: no such table: django_site". This seems to create an empty db file in the location specified in the settings.py.
5] I read the other stack-overflow posts about this error and tried commenting both django.contrib.sites and django.contrib.sessions from my installed apps as that worked for some people, it has not for me. I also tried using python manage.py migrate as I have south in my installed apps and it was mentioned in another post but no luck for me.
I believe I am doing something fundamentally wrong in this process as I was able to do it just fine at work weeks ago and that dev machine still works fine.
I'm not the most adept individual when it comes to Linux and I may have some kind of path issue or what have you. Any help would be great!

Do this:
pip install south
Add south to INSTALLED_APPS.
And run ./manage.py syncdb
and ./manage.py migrate

Related

no errors thrown when running pipenv install, but running a python manage.py migrate after results in errors

ModuleNotFoundError: No module named 'django_on_heroku'
I've got a new machine at work and I'm attempting to run an old project which I've cloned. Cannot get the api server up and running.
(ps, my first stack overflow post -- sorry if the format isn't great or specific enough!)
Have tried installing django on heroku in the pipenv - that is sucesfull, the error reoccurs though on the next dependency when i attempt a migrate and then run server.

How can you change your python code after you deploy it to heroku using git , without downloading and reinstalling requirements everytime? [duplicate]

Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.

heroku keeps installing django packages during each deployment

Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.

Django, reset South migrations

Recently, I moved from Linux Mint to Ubuntu, uploaded my project's code to Github, downloaded it again and tried to continue developing. But I have a problem with South:
I tried migrating the apps(many apps) normally:
manage.py schemamigration apps --auto,
But I got:
"You cannot use --auto on an app with no migrations. Try --initial."
Then I tried '--initial',
But when I migrated the apps '$ ./manage.py migrate apps', I got:
"These migrations are in the database but not on the disk:
...(all the migrations I had, not sure how they ended up there)
I'm not trusting myself; either fix this yourself by fiddling
with the south_migrationhistory table, or pass --delete-ghost-migrations
to South to have it delete ALL of these records (this may not be good)."
I don't care about keeping the migrations so I tried python manage.py --delete-ghost-migrations, but I got "Unknown command".
Then I tried reseting migrations the way this post recommends, so I did:
$ python manage.py reset south
But I got "Unknown command" again.
¿How can I fix this so I can keep working on my project? Sorry if it is something obvious.
*When I was working on Linux Mint I used Mysql, now on Ubuntu I intalled Postgre. This probably doesn't have anything to do with the error cause I think I got it right and configured it correctly with my django project. But maybe you should know it if the solution needs some database manipulation. Thanks in advance.
Use the following command to clear the database:
./manage.py sqlclear south | ./manage.py dbshell
then make sure to remove the migrations directory in the app to fully reset south:
rm [app_name]/migrations

NoMigrations error in Django

I am building an app called 'competencies'. I made changes to models, migrated the app locally, and everything worked. This is my eighth migration on the app.
I have deployed the app on heroku, so I committed changes and pushed to heroku. I can see that the changes went through, because the new migrations appear in the heroku files. When I log in to heroku and try to migrate the competencies app, I get the following error:
NoMigrations: Application '<module 'django.contrib.admin' from '/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/__init__.py'>' has no migrations.
I have searched for this error, and I have not found anything meaningful. Can anyone suggest what I am doing wrong, or how to address the issue?
django.contrib.admin should not have migrations. Contrib packages are not south managed.
If you EVER ran python manage.py schemamigration django.contrib.auth --XXX on your local it would create the migrations folder in your local copy's install of the venv's django. However, this will never get transferred to heroku.
test something for me. create a new copy of your site on your local machine
new DB
new virtualenv
new folder w/ new clone of repo
try to run python manage.py migrate if you get the same error its b/c you broke your virtualenv with south.
Something else you could try IF your database models have not changed a bunch since the last working copy:
roll your models back to the last working configuration
delete EVERY app's migrations folder
truncate south_migrations table
run python manage.py schemamigration --initial X for each of your apps.
push and migrate --fake
redo your model changes
create migrations for the model changes
push and migrate regularly
I recently encountered this error after dumping a live database to a dev box for testing data migrations.
One of the dependencies was throwing this error (specifically taggit). I think that I have a different version of taggit on the dev box which does not have migrations, but the database I dumped had two migrations for taggit in south_migrationhistory.
I deleted the entries in south_migrationhistory for the problem app erroneously claiming NoMigrations and that solved my problem. Everything's running again.
Apart from many answers posted above, south.exceptions.NoMigrations is often exception after 2014 (Django 1.7) because of changed migrations directory. The directory is default for Django built in migrations.
For south migration, the directory is south_migrations. South>=1.0 can recognize this and automatically detect migrations. See details here on Django docs
In this case, update South:
pip install -U South
Or you can also specify migration directory on settings file (for every app installed).
I found an odd edge case, involving Kombu.
I'm maintaining a legacy Django 1.5 project on Ubuntu 14.04, and I previously had this setting to get Kombu to play nicely:
SOUTH_MIGRATION_MODULES = {
'kombu_transport_django': 'kombu.transport.django.south_migrations',
}
However, after I upgraded to Ubuntu 16, there were some minor tweaks in the Python stdlib that again broke Kombu. Upgrading Kombu was the only immediate solution, but that gave me another Kombu error similar to what OP found:
NoMigrations: Application '<module 'kombu.transport.django' from '/myproject/.env/local/lib/python2.7/site-packages/kombu/transport/django/__init__.pyc'>' has no migrations.
This error message is nearly worthless, but I eventually realized the problem was my SOUTH_MIGRATION_MODULES setting. It turns out, the old kombu.transport.django.south_migrations was removed, and South trying to import this missing migration directory is what was causing the error. The fix was to remove that line.
Try pip install --upgrade django
The NoMigrations error often shows up if you downgrade your Django version.
In my case, I had installed a package which automatically uninstalled my current Django version and installed a downgraded it.
Installing the updated version was a quick fix.
Also, you may want to check in your INSTALLED_APPS if you have included all of your apps including the 'django.contrib.auth' and 'django.contrib.admin'

Categories