Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django DatabaseError: relation "django_site"

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

like image 542
user1940979 Avatar asked Jul 26 '13 21:07

user1940979


2 Answers

You may be calling a site object before creating site model(before syncdb)

ex: site = Site.objects.get(id=settings.SITE_ID)

like image 74
Geo Jacob Avatar answered Oct 28 '22 11:10

Geo Jacob


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

like image 24
KhoPhi Avatar answered Oct 28 '22 10:10

KhoPhi