问题描述
该网站工作得很好,直到我点击注销我的应用程序。之后,网站会给我这个错误:
在/ login /
上的NotNotExist站点匹配查询不存在。
我搜索到任何地方,我唯一的解决方案涉及设置网站框架,SITE_ID等。我认为这些项目在我的电脑上是好的,但我找不到一个演练/指南,以帮助我检查他们。
任何人都可以告诉我问题是什么以及如何解决?提前感谢:3
DATABASES = {
'default':{
'ENGINE':' django.db.backends.sqlite3',#添加'postgresql_psycopg2','postgresql','mysql','sqlite3'或'oracle'。
'NAME':'/home/dotcloud/nhs.db',#或使用sqlite3的数据库文件路径。
'USER':'',#不与sqlite3一起使用。
'PASSWORD':'',#不与sqlite3一起使用。
'HOST':'',#设置为localhost的空字符串。不适用于sqlite3。
'PORT':'',#设置为空字符串为默认值。不适用于sqlite3。
}
}
如果您的数据库中没有定义网站,并且django想要引用它,则需要创建一个。
从 python manage.py shell
:
from django.contrib.sites.models import Site
new_site = Site.objects.create(domain ='foo.com',name ='foo.com')
print new_site.id
现在将您的settings.py中的网站ID设置为SITE_ID
Python noob, as in this is my first project, so excuse my unfamiliarity.
The site was working very well until I clicked "log out" on my app. After that, the website would give me this error:DoesNotExist at /login/Site matching query does not exist.
I searched everywhere and the only solution I get relates to setting up the site framework, SITE_ID, etc. I think those items on my computer are fine, but I can't find a walkthrough/guide to help me check on them.
Can anyone tell me what the problem is and how to fix it? Thanks in advance :3
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/home/dotcloud/nhs.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
If you don't have a site defined in your database and django wants to reference it, you will need to create one.
From a python manage.py shell
:
from django.contrib.sites.models import Site
new_site = Site.objects.create(domain='foo.com', name='foo.com')
print new_site.id
Now set that site ID in your settings.py to SITE_ID
这篇关于站点匹配查询不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!