Initially i started one project in Django installed cms , admin and few other apps.
Then i started new project , it was working fine . But now when i try to add same apps like cms , backend admin then i get his error
Not synced (use migrations):
- sentry
- cms
- menus
- cms.plugins.text
- cms.plugins.picture
- cms.plugins.link
- cms.plugins.file
- cms.plugins.snippet
- cms.plugins.googlemap
i want to know that why this happens. Can i install only one project in django
I am using different databases for those different projects and they have their own manage.py.
There may be the other reason for error but i just think that may be the reason
Your project seems to use South as a migration tool. You are required to 'migrate' the apps by typing:
python manage.py migrate
Related
There is a really old thread on stackoverflow here Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb
but the difference that I have with their issue is that my containers have the POSTGIS and POSTGRES installed in. Specifically I used QGIS and the image is like so
db:
image: kartoza/postgis:13.0
volumes:
- postgis-data:/var/lib/postgresql
So locally I have two docker images - one is web and the other is the kartoza/postgis
I also have this as well in the settings.py file
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
which should support the GIS data. I see all my packages gis, geolocation packages installed with no issues. But I am getting the above error when I run heroku run python manage.py migrate
The website runs with very limited functionality as the geo variables are needed to get you past the landing page.
The steps I have taken to deploy is
heroku create appname
heroku stack:set container -a appname
heroku addons:create heroku-postgresql:hobby-dev -a appname
heroku git:remote -a appname
git push heroku main
EDIT The db url on heroku is postgres://foobar:3242q34rq2rq32rf3q2rfq2q2r3vq23rvq23vr#er3-13-234-91-69.compute-
I have also ran the below command and it shows that the db now takes GIS, but I still get the error
$ heroku pg:psql
create extension postgis;
try replacing db with localhost
heroku config:add DATABASE_URL=postgis://foo:bar#localhost:5432/gis
Ok so after 14 or so hours of reading. The issue here is that
Heroku database does NOT have qgis capabilities enabled as a default - you have to use heroku pg:psql then run CREATE EXTENSION postgis;
Having QGIS installed within the docker container results it not being able to perform functions such as hero pg:push localdatabase -postgresqlremoteherokudb and heroku config:add DATABASE_URL=postgis://foo:bar#localhost:5432/gis So if anyone is following the python nearbyshops tutorial, you might end up here as well. I got fixated here thinking it's a db issue, but it was more so to do with heroku configuration settings.
If you are coming here from docker, which might mean you need to install django_heroku package to modify your settings. There are recent 2019 and 2018 guides on how to deploy Geospatial apps to heroku, but again, you don't need those. (at least for me I didn't)
GIS now is available as an extension, you no longer need to add buildpacks.
There are still some configuration issues if you are using gunicorn for staticfiles, so the website at first won't launch properly. Highly suggest that you track your heroku log errors (manual settings.py coding or heroku addons).
After updating the django settings.py default database to correct values.
i am able to run makemigrations and migrate command and also create super user. but when i login to the admin it gives me error of “no such table - auth user, OPERATIONAL ERROR”.
I noticed that even if i delete db.sqlite3 file, it comes back when i try to login, i think django looks for table in db.sqlite3 and not postgres.
why db.sqlite3 file re appear after deleting ?
how do i correctly configure my settings.py ?
i am integration using digitalocean managed database services with django installed in one droplet, i have integrated both preciously without error but i installed postgres, this is the first time using managed database service.
Thanks
It seems that your django settings are still pointing to the SQlite database.
Did you reload your WSGI process ? If not, the old SQlite settings are still used in memory.
I'm trying to deploy a django CMS app to PythonAnywhere or Heroku but I keep getting this error on Heroku:
ProgrammingError at /
relation "cms_urlconfrevision" does not exist
LINE 1: ...sion"."id", "cms_urlconfrevision"."revision" FROM "cms_urlco...
and this error on PythonAnywhere:
OperationalError at /
no such table: cms_urlconfrevision
The app works fine on localhost.
I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.
I'm using
django-cms==3.6.0
Django==2.1.8
I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.
Migration files just define what migrations exist. They don't modify your database by themselves. There are two steps here:
Creating migrations with makemigrations. This should only be done on your development machine. By the time your code is being deployed you shouldn't have any model changes that would cause new migrations to be generated.
Applying migrations to your database with migrate. This must be done in development (to update your local database) and also in production (to update your production database).
On Heroku, you'd run your migrations with
heroku run python manage.py migrate
I think this is the step you're missing.
Hello maybe you found the solution but if the is somebody coming across that issue, it due to the database settings.
In project_name/site_name/settings.py and database settings section
Change
NAME: 'project.db'
to
NAME:'project_name/project.bd'
in the file setting.py change
'NAME': 'project.db',
to
'NAME': BASE_DIR / 'project.db',
worked for me
I've set up a new Django project (based on the template django cookie cutter) but get a postgres error when trying to migrate the database for the first time
psycopg2.ProgrammingError: relation "django_site_domain_a2e37b91_uniq" already exists
I'm not clear what the issue is or how best to diagnose?
What is SITE_ID?
Django was created from a set of scripts developed at a newspaper to
publish content on multiple domains; using one single content base.
This is where the "sites" module comes in. Its purpose is to mark
content to be displayed for different domains.
In previous versions of django, the startproject script automatically
added the django.contrib.sites application to INSTALLED_APPS, and when
you did syncdb, a default site with the URL example.com was added to
your database, and since this was the first site, its ID was 1 and
that's where the setting comes from.
Keep in mind that starting from 1.6, this framework is not enabled by
default. So if you need it, you must enable it
The SITE_ID setting sets the default site for your project. So, if you
don't specify a site, this is the one it will use.
Ways to fix this:
Increment SITE_ID:
1. Increment `SITE_ID` variable in settings.py
2. python manage.py makemigrations
3. python manage.py migrate --run-syncdb
Cons: Had to increment SITE_ID without good reason
Attempt to migrate without --run-syncdb:
1. python manage.py makemigrations
2. python manage.py migrate
Note: May have to try multiple times before it works. Unsure why, possibly because I was in the process of deleting the pvc
According to the Django docs, if I want to create an initial migration for an app, I should do:
$ python manage.py makemigrations my_app
However, if I do that in my project, I get:
No changes detected in app 'my_app'
even though there are no migrations for my_app yet - the my_app/migrations/ folder only has an __init__.py file.
I do NOT have managed = False in my model. The model classes in question don't even have a Meta class defined. What else can prevent Django from detecting model changes?
How does Django detect if/when there are changes?
Update:
I should add that migrations for this particular app worked fine back when I was using South migrations. It's only after upgrading to Django 1.7, and built-in migrations, that it can no longer figure out if/when there are model changes for that particular app (migrations for other apps work fine).
A little late, but having just hit this after creating a brand new app, it suddenly dawned on me that I hadn't added the new app to the INSTALLED_APPS in the settings.py.
INSTALLED_APPS = (
...
my_app,
...
)
Doing that and then re-running python manage.py makemigrations my_app generated the initial migration.
You might want to look for a "migrations" directory somewhere in your virtualenv home directory or on your path.
I ran a few times into some similar issue, when trying to migrate an app from South to Django 1.7 migrations. For some reason, Django wouldn't find the correct migrations folder, and so would create the migration into an unlikely location such as <virtualenv>/bin/myapp/migrations dir (when using django-admin.py). So everytime I'd run makemigrations Django would find this "stale" migration, and display the No changes detected in app 'my_app' message.
Sorry if I'm vague on the specifics, I'll update next time I run into this issue.