小编典典

网站匹配查询不存在

django

Python noob,因为这是我的第一个项目,所以请原谅我。

在我单击应用程序上的“注销”之前,该网站运行良好。在那之后,网站会给我这个错误:/ login /的SiteNotExist不存在网站匹配查询。

我到处搜索,获得的唯一解决方案与设置站点框架,SITE_ID等有关。我认为计算机上的这些项目都不错,但是找不到帮助你进行检查的演练/指南。

谁能告诉我问题出在哪里以及如何解决?在此先感谢: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.
    }
}

阅读 579

收藏
2020-03-27

共1个答案

小编典典

如果你的数据库中没有定义站点,而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。

2020-03-27