我已经启动了新的django项目并启用了管理员应用程序.我可以登录管理站点,但是当我尝试添加/更改站点或用户时,我正在获取
CSRF verification failed. Request aborted.
Reason given for failure:
CSRF token missing or incorrect.
Run Code Online (Sandbox Code Playgroud)
这就是我在settings.py中所拥有的:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
Run Code Online (Sandbox Code Playgroud)
当我查看管理页面来源时,我看到了
<input type='hidden' name='csrfmiddlewaretoken' value='T9Mfk1LRXi5jPE2dh5jcvdKwzYM6Iy5I' />
Run Code Online (Sandbox Code Playgroud)
那里
我有Django版本1.4.1