当前位置:   article > 正文

ERRORS: ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEW

?: (admin.e408) 'django.contrib.auth.middleware.authenticationmiddleware' mu

完整报错如下:

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/management/base.py", line 436, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.
?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application.
?: (admin.E410) 'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.
 

解决方案:

  1. MIDDLEWARE_CLASSES = (
  2.     'django.contrib.sessions.middleware.SessionMiddleware',
  3.     'django.middleware.common.CommonMiddleware',
  4.     'django.middleware.csrf.CsrfViewMiddleware',
  5.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  6.     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  7.     'django.contrib.messages.middleware.MessageMiddleware',
  8.     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  9.     'django.middleware.security.SecurityMiddleware',
  10.     'oscar.apps.basket.middleware.BasketMiddleware',
  11.     'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',    
  12. )


 

改成:

  1. MIDDLEWARE  = [
  2.     'django.contrib.sessions.middleware.SessionMiddleware',
  3.     'django.middleware.common.CommonMiddleware',
  4.     'django.middleware.csrf.CsrfViewMiddleware',
  5.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  6.     # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  7.     'django.contrib.messages.middleware.MessageMiddleware',
  8.     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  9.     'django.middleware.security.SecurityMiddleware',
  10.     'oscar.apps.basket.middleware.BasketMiddleware',
  11.     'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'  
  12. ]


改变的地方有3处

①MIDDLEWARE_CLASSES->MIDDLEWARE

②元组()改成列表[]

③'django.contrib.auth.middleware.SessionAuthenticationMiddleware',在Django新版本中删除

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/71731?site
推荐阅读
相关标签
  

闽ICP备14008679号