Admin login stopped functioning Django

*爱你&永不变心* 提交于 2019-12-03 15:57:38

Check out this thread, it seems relevant.

From the last post:

Since the exception said " 'Site' matching query does not exist", and the docs said something about the SITE_ID describing the site in the django_site database table, I went ahead and took a look at my (sqlite) database. The django_site table was empty, so I added a row with id==1 (the same that I have in settings.py) and then it worked.

If you don't mind loosing your data, you can try to run 'sql appname', as this table was supposed to be built automatically.

Try commenting or deleting 'django.contrib.sites' from the INSTALLED_APPS setting on your settings.py, that should solve the problem.

You can also check your sites table:

python manage.py shell
from django.contrib.sites.models import Site
Site.objects.all()

And if there is no site defined for localhost, you can create it or re-create it:

Site.objects.create(pk=1, domain='127.0.0.1:8000', name='localhost')

That worked for me.

Ken T.

For anyone trying to install django-allauth for django 1.8 or above and getting this error after following the instructions here:

http://django-allauth.readthedocs.org/en/latest/installation.html

Just add the following line to urls.py:

from django.contrib.sites.models import Site

Hope this saves someone time.

INSTALLED_APPS = [ .... 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', ....bla bla bla ] SITE_ID = 1

try add SITE_ID=1 ..it worked for me

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