8

I am following from the docs of django-disqus to use it in my project. I have installed it in my settings, with other needed settings (API key and short name). But when I try to run these commands:

>>> from django.contrib.sites.models import Site
>>> Site.objects.all()

I am getting an error:

OperationalError: no such table: django_site

I have already installed django.contrib.admin in my settings and is using it in my project. So what am I missing?

halfer
  • 19,824
  • 17
  • 99
  • 186
Robin
  • 5,366
  • 17
  • 57
  • 87

3 Answers3

26

Make sure you have added 'django.contrib.sites' to your INSTALLED_APPS, then run migrate to create the required table.

python manage.py migrate
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Yes, that was it. Thank you. – Robin Jun 16 '15 at 19:05
  • I'm still having one problem though. When I visit the page, its giving me this error: `You're using the Django "sites framework" without having set the SITE_ID setting`. Where do I add the SITE_ID? Please help me. – Robin Jun 16 '15 at 19:22
  • In your settings.py.see [here](https://docs.djangoproject.com/en/1.8/ref/contrib/sites/#enabling-the-sites-framework) for full instructions. – Alasdair Jun 16 '15 at 19:58
  • 1
    This didn't work for me. I'm getting this error with `manage.py test`, even though I have `django.contrib.sites` in my `INSTALLED_APPS`. – Cerin Sep 30 '16 at 20:29
  • @Cerin that sounds like an unrelated issue. Since you are running the tests, the table is probably missing from the test database in your case. – Alasdair Sep 30 '16 at 22:24
0

For me it is working only if I do the migration before starting using the Site app. I have to remove all the imports in the code then makemigration/migrate. After that I start using the Site app.

Tanon
  • 1
  • 1
0

Had this issue because I had an exit(1) (error code) in a migration of mine. All migrations were not run, that was the hint.

Ehvince
  • 17,274
  • 7
  • 58
  • 79