[英]DoesNotExist at /admin/login/ after upgrading to Django 1.8
After upgrade from django 1.7 to 1.8, I can't able to access my admin portal. 从Django 1.7升级到1.8后,我无法访问我的管理门户。 I get the following error:
我收到以下错误:
DoesNotExist at /admin/login/
Site matching query does not exist.
As mentioned in other questions, I have change my TEMPLATES
setting, but it does not help. 如其他问题所述,我更改了
TEMPLATES
设置,但这无济于事。
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'MyANSRSource/templates/MyANSRSource/'),
os.path.join(BASE_DIR, 'employee/template/'),
os.path.join(BASE_DIR, 'employee/emp_photo/'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
#global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
# 'django.template.context_processors.request',
#),
# list if you haven't customized them:
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
If you don't have SITE_ID
in your settings, Django 1.8, will try to use the hostname (eg 127.0.0.1:8000
) to find the site. 如果您的设置中没有
SITE_ID
,则Django 1.8将尝试使用主机名 (例如127.0.0.1:8000
)来查找站点。 If you don't have a site with that domain name in your database, then you will get the error: 如果您的数据库中没有使用该域名的站点,则将收到错误消息:
Site matching query does not exist.
You have a few options: 您有几种选择:
'django.contrib.sites'
from your INSTALLED_APPS
setting. INSTALLED_APPS
设置'django.contrib.sites'
其从'django.contrib.sites'
删除。 SITE_ID
to the value of the site you want to use. SITE_ID
设置为您要使用的网站的值。 SITE_ID = 1
will probably work, if you haven't made any changes to the sites in the database. SITE_ID = 1
可能会起作用。 example.com
to 127.0.0.1:8000
). example.com
更改为127.0.0.1:8000
)。 This is the most fragile fix, because your project will now work for 127.0.0.1:8000
, but not for localhost:8000
. 127.0.0.1:8000
,但不适用于localhost:8000
。 Try to create a new user by running the command manage.py createsuperuser
. 尝试通过运行命令
manage.py createsuperuser
创建一个新用户。 Log in with this user, you should be able to access the admin panel now. 使用该用户登录,您现在应该可以访问管理面板。
Then find your user object and make sure it has the correct permissions. 然后找到您的用户对象,并确保它具有正确的权限。 as stated in the 1.8 changelog under Minor features .
如1.8更新日志中次要功能所述 。
When I upgraded I lacked the correct permission to access the admin panel. 升级后,我没有访问管理面板的正确权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.