Reputation: 935
I currently have a django app am developing on my PC with data in my db but when i try running this app on a test server i get the error below
DatabaseError: relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
can any one tell me why am getting this error please.thanks
Upvotes: 11
Views: 9484
Reputation: 926
My "commenting out" pattern was slightly different than the accepted answers (as shown below). That is to say, it might be unique depending on the values of various dependencies scattered throughout your app. If commenting out the values above throws an error message, I recommend commenting out the apps that throw the error message and uncommenting accordingly until it works for you. This may be a little "brute force" but it should get the job done.
INSTALLED_APPS = [
# django native apps
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
"django.forms",
'django.contrib.gis',
# 'django.contrib.flatpages',
#third party apps
#django-allauth apps
'allauth',
# 'allauth.account',
# 'allauth.socialaccount',
# 'allauth.socialaccount.providers.facebook',
# 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.twitter',
# 'allauth.socialaccount.providers.github',
# my apps
'app0',
'app1',]
#MIGRATION_MODULES = {"sites": "mysite.contrib.sites.migrations"}
Upvotes: 0
Reputation: 9616
I overcame this issue with the following order in INSTALLED_APPS
:
INSTALLED_APPS = (
'django.contrib.sites',
'allauth',
'allauth.account',
# my other apps,
)
Upvotes: 0
Reputation: 37600
Couple of things you can try and check:
settings.py
should have a SITE_ID
usually = 1
INSTALLED_APPS
in your settings.py
and try temporarily commenting items out.site = Site.objects.get(id=settings.SITE_ID)
).Once you got it working, remember to manage.py makemigrations APP_NAME
as I found cases where it seem to have then avoided the commenting out step.
Upvotes: 1
Reputation: 1
Also make sure SITE_ID = 1 comes before the DATABASE definition in settings.py
Upvotes: -2
Reputation: 9517
This issue continues to plague many, including myself. Although a tedious process, this approach saves me the brain power:
Disable all external apps in your INSTALLED_APPS, except your own apps, like so:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'main', # This is my own app.
# 'compressor',
# 'ckeditor',
# 'imagekit',
# 'debug_toolbar',
# 'rest_framework',
# 'allauth',
# 'allauth.account',
# 'allauth.socialaccount',
# 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.facebook',
)
Run
python manage.py makemigrations
python manage.py migrate
Then, uncomment all the other apps, then repeat makemigrations and migrate above.
That works all the time for me
Upvotes: 5
Reputation: 1448
Had this strange issue while initiating a new database and using django-debug-toolbar. Removed it from the INSTALLED_APPS
and was able to run syncdb
. Then re-added debug_toolbar and it was still working fine.
If you're using django-debug-toolbar, try to comment out debug_toolbar
in your installed apps and try again.
Update: Please follow the steps for the explicit setup: http://django-debug-toolbar.readthedocs.org/en/1.2.2/installation.html#explicit-setup
Upvotes: 4
Reputation: 1205
i have same problem and fixed it like this:
SITE_ID=1
into settings.py
run this command :
python manage.py migrate
Upvotes: 3
Reputation: 935
not been able to solve this a django way so i tried using sql, i created a dump of just the database like this.
pg_dump mypgdatabase | gzip -c > mypgdatabase.dump.out.gz
then moved it to the server
scp /path/to/mypgdatabase.dump.out.gz my_remote_server
then recreated it on the server like this
psql -d mypgdatabase -f mypgdatabase.dump.out
then run
./manange.py migrate --all
and all when well.
Upvotes: 2
Reputation: 6009
You may be calling a site object before creating site model(before syncdb)
ex: site = Site.objects.get(id=settings.SITE_ID)
Upvotes: 8
Reputation: 1066
I can't see your models or what apps are you using, but my guess is that you are using django_site (Site model) and you don't have 'django.contrib.sites' in the INSTALLED_APPS.
If I'm correct then just add 'django.contrib.sites',
to your INSTALLED_APPS
.
Upvotes: 4