站点匹配查询不存在。查询参数为{'pk':3} [英] Site matching query does not exist. Lookup parameters were {'pk': 3}

查看:70
本文介绍了站点匹配查询不存在。查询参数为{'pk':3}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Environment:

Request Method: GET
Django Version: 1.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.facebook',
 'allauth.socialaccount.providers.google',
 'allauth.socialaccount.providers.linkedin',
 'django.contrib.admin',
 'django.contrib.admindocs')


Installed Middleware:

('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)
File "/var/www/sampleapp/allauth/account/views.py" in dispatch
  41.                                                                     **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
  86.         return handler(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/edit.py" in get
  155.         return self.render_to_response(self.get_context_data(form=form))
File "/var/www/sampleapp/allauth/account/views.py" in get_context_data
  67.                 "site": Site.objects.get_current(),
File "/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current
  26.             current_site = self.get(pk=sid)
File "/usr/local/lib/python2.7/dist-packages/django/d
b/models/manager.py" in get
  143.         return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
  401.                 (self.model._meta.object_name, kwargs))

Exception Type: DoesNotExist at /accounts/login/
Exception Value: Site matching query does not exist. Lookup parameters were {'pk': 3}

我是新来的django,
帮助我解决这个问题?

I am new to django, Help me to fix this issue?

推荐答案

我也遇到这个问题。我正在浏览 PyCharm Django指南。我通过删除我的sqlite数据库文件并再次运行syncdb来修复此问题。我不知道为什么它第一次没有工作,但现在工作。

I encountered this problem as well. I was going through the PyCharm Django guide. I fixed this by deleting my sqlite database file and running syncdb again. I don't know why it didn't work the first time, but it works now.

另外,这可能值得下载 SQLite数据库浏览器,以便您可以看到SQLite数据库的实际结构。对于这个问题,您对django_site表感兴趣。在我删除了我的数据库文件并重新启动syncdb后,此表中有一行。

Also, it's probably worth downloading the SQLite Database Browser so that you can see the actual structure of your SQLite database. For this issue, you're interested in the django_site table. After I deleted my database file and reran syncdb, there was one row in this table.

这篇关于站点匹配查询不存在。查询参数为{'pk':3}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆