AttributeError:运行django-maintenancemode时,'module'对象没有属性'__all__'

时间:2013-07-11 04:49:15

标签: python django

尝试在django中运行此中间件时遇到此错误。 https://github.com/shanx/django-maintenancemode

它正在返回

AttributeError: 'module' object has no attribute '__all__'.

我有什么问题吗?我试图在virtualenv中的本地主机环境中测试他的。我已将中间件放入设置文件中,无论我将模式设置为true还是false,都会返回此错误。我在我的模板文件夹中放置了一个503.html模板,我想让它服务。

回溯

    Traceback (most recent call last):
  File "C:\python27\Lib\wsgiref\handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\contrib\staticfiles\handlers.py", line 72, in __call__
    return self.application(environ, start_response)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\core\handlers\wsgi.py", line 236, in __call__
    self.load_middleware()
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\core\handlers\base.py", line 51, in load_middleware
    mod = import_module(mw_module)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django_maintenancemode-0.9.3-py2.7.egg\maintenancemode\middleware.py", line 6, in <module>
    defaults.__all__.append('handler503')
AttributeError: 'module' object has no attribute '__all__'
[11/Jul/2013 14:57:57] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
  File "C:\python27\Lib\wsgiref\handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\contrib\staticfiles\handlers.py", line 72, in __call__
    return self.application(environ, start_response)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\core\handlers\wsgi.py", line 236, in __call__
    self.load_middleware()
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\core\handlers\base.py", line 51, in load_middleware
    mod = import_module(mw_module)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Users\Deep.C\.virtualenvs\dcwebdev\lib\site-packages\django_maintenancemode-0.9.3-py2.7.egg\maintenancemode\middleware.py", line 6, in <module>
    defaults.__all__.append('handler503')
AttributeError: 'module' object has no attribute '__all__'

1 个答案:

答案 0 :(得分:0)

你使用的是版本0.9.3,它是旧的,不受支持,并且与最新版本的Django相冲突。升级到0.10,你会得到一些有用的东西。

The critical line现在修改the correct object; django.conf.urls.default no longer has __all__ defined