No such table as django_site

我的未来我决定 提交于 2019-12-23 16:42:50

问题


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?


回答1:


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

python manage.py migrate



回答2:


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.



来源:https://stackoverflow.com/questions/30875662/no-such-table-as-django-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!