小编Jas*_*ert的帖子

Django - 不正确的配置:模块"django.contrib.auth.middleware"

我正在运行virtualenv尝试学习Django,但无论出于何种原因安装Django后,当我尝试访问默认的Django起始页时,我在浏览器中收到以下错误:

发生服务器错误.请联系管理员.

在我运行服务器的终端窗口中显示以下错误:

配置不当:模块"django.contrib.auth.middleware"未定义"SessionAuthenticationMiddleware"属性/类

如果有人知道为什么我在virtualenv中遇到这个错误,我会很感激.不过,我可以让服务器在非virtualenv设置中正确运行.

这是完整的堆栈跟踪:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__
    self.load_middleware()
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
    mw_class = import_by_path(middleware_path)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/module_loading.py", line 31, in import_by_path
    error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
[16/Sep/2014 22:44:30] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/wsgi.py", line …
Run Code Online (Sandbox Code Playgroud)

python django virtualenv

29
推荐指数
4
解决办法
3万
查看次数

TypeError:格式字符串的参数不足 - 使用While循环

我正在做旧的99瓶歌并尝试使用While循环,以帮助我继续更好地学习循环类型.

我想知道为什么我在下面的代码中会得到一个TypeError,而我错过了什么参数呢?

这是我的代码:

# Get number of beers
bottles = int(raw_input("How many bottles of beer? "))

# return invalid response
if bottles < 1:
    print "That's not a good number"

    if bottles == 1:
        s1 = "bottle" 
        s2 = "bottles" 

    elif bottles == 2:
        s1 = "bottles" 
        s2 = "bottles" 

# sing verses
while bottles > 0:
    print "%d %s of beer on the wall," % bottles, s1
    print "%d %s of beer." % bottles, s1
    print "You take one …
Run Code Online (Sandbox Code Playgroud)

python

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

django ×1

virtualenv ×1