如何解决导入错误:模块“django.middleware.csrf”未定义“Cs rfViewMiddleware”属性/类

lymnna71  于 2022-12-14  发布在  Go
关注(0)|答案(1)|浏览(71)

我正在做一个django项目,在我成功注册和登录表单后,我已经登录到管理面板,不久之后不知何故我得到了这个错误:


settings.py

INSTALLED_APPS = [

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'crispy_forms',
    'django_filters',
    'startup',
    'vereinsapp',
    'users',
    #'users.apps.UsersConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.Cs‚rfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

WSGI_APPLICATION = 'startup.wsgi.application'

LOGIN_REDIRECT_URL = '/'

有人知道我可以尝试什么来修复它吗?我还尝试删除apps.py“users”的www.example.com文件。这是我的项目结构:

oug3syen

oug3syen1#

在中间件中替换此行

'django.middleware.csrf.Cs‚rfViewMiddleware'

带下划线

'django.middleware.csrf.CsrfViewMiddleware',

相关问题