码迷,mamicode.com
首页 > 其他好文 > 详细

Django

时间:2016-10-22 20:58:33      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:sel   pre   prevent   cat   oca   line   and   hand   port   

Last Update : 10/22/2016 19时18分

 

常见问题

ImproperlyConfigured: Middleware module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" class

 

运行python manage.py runserver时出现下面错误

Traceback (most recent call last):

  File "D:\Python27\lib\wsgiref\handlers.py", line 85, in run

    self.result = application(self.environ, self.start_response)

  File "D:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 72, in __call__

    return self.application(environ, start_response)

  File "D:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 236, in __call__

    self.load_middleware()

  File "D:\Python27\lib\site-packages\django\core\handlers\base.py", line 57, in load_middleware

    raise exceptions.ImproperlyConfigured(‘Middleware module "%s" does not define a "%s" class‘ % (mw_module, mw_classname))

ImproperlyConfigured: Middleware module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" class

SessionAuthenticationMiddleware 这个是1.7里新加的,把 django版本升级就可以解决这个问题

 

如何查看 django版本?

import django

django.VERSION

 

还有一个方法是在 settings.py里删除SessionAuthenticationMiddleware

MIDDLEWARE_CLASSES = (

    ‘django.contrib.sessions.middleware.SessionMiddleware‘,

    ‘django.middleware.common.CommonMiddleware‘,

    ‘django.middleware.csrf.CsrfViewMiddleware‘,

    ‘django.contrib.auth.middleware.AuthenticationMiddleware‘,

    ‘django.contrib.auth.middleware.SessionAuthenticationMiddleware‘ ,

    ‘django.contrib.messages.middleware.MessageMiddleware‘,

    ‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,

    ‘django.middleware.security.SecurityMiddleware‘,

)

 

SNIMissingWarning & InsecurePlatformWarning

D:\virtualenv\lwc-ws>pip install django==1.8

Collecting django==1.8

C:\Python27\lib\site-packages\pip-8.1.1-py2.7.egg\pip\_vendor\requests\packages

urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but

the SNI (Subject Name Indication) extension to TLS is not available on this pla

tform. This may cause the server to present an incorrect TLS certificate, which

can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.

  SNIMissingWarning
C:\Python27\lib\site-packages\pip-8.1.1-py2.7.egg\pip\_vendor\requests\packages

urllib3\util\ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is n

ot available. This prevents urllib3 from configuring SSL appropriately and may c

ause certain SSL connections to fail. For more information, see https://urllib3.

readthedocs.org/en/latest/security.html#insecureplatformwarning.

  InsecurePlatformWarning

 

解决方法:

在cmd中输入:

pip install pyopenssl ndg-httpsclient pyasn1

 

 

Could not find a version that satisfies the requirement djangocms-installer (from versions: )

No matching distribution found for djangocms-installer

使用-vvv打开debug信息

(django-cms) D:\virtualenv\django-cms>pip install djangocms-installer -vvv
Collecting djangocms-installer
  1 location(s) to search for versions of djangocms-installer:
  * https://pypi.python.org/simple/djangocms-installer/
  Getting page https://pypi.python.org/simple/djangocms-installer/
  Looking up "https://pypi.python.org/simple/djangocms-installer/" in the cache
  No cache entry available

  Starting new HTTPS connection (1): pypi.python.org

最后发现是fiddler开了的原因,关了就好了

 

django.core.exceptions.ImproperlyConfigured: LANGUAGE_CODE "zh-cn" must have a matching entry in LANGUAGES

https://docs.djangoproject.com/en/1.8/ref/settings/

 

 

 

 

 

 

Django

标签:sel   pre   prevent   cat   oca   line   and   hand   port   

原文地址:http://www.cnblogs.com/2dogslife/p/5988201.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!