当我从dj_static导入cling时出错

时间:2014-04-29 17:08:47

标签: django heroku

我想在Heroku中部署django项目,但应用程序经常崩溃。 我意识到dj_static导入Cling

中的

我安装了dj_static。

(venv)alex@PC:~/projects/hellodjango$ pip freeze
Django==1.6.4
dj-static==0.0.5
...

但发生以下错误:

>>> from dj_static import Cling
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/dj_static.py", line 8, in <module>
    from django.contrib.staticfiles.handlers import StaticFilesHandler as DebugHandler
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 8, in <module>
    from django.contrib.staticfiles.views import serve
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/contrib/staticfiles/views.py", line 13, in <module>
    from django.views import static
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/views/static.py", line 96, in <module>
    template_translatable = ugettext_noop("Index of %(directory)s")
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 65, in gettext_noop
    return _trans.gettext_noop(message)
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 52, in __getattr__
    if settings.USE_I18N:
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/home/alex/projects/hellodjango/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

如何解决这个问题?

0 个答案:

没有答案