2011-04-24 64 views
0

我應該在哪裏放置filebrowser的擴展設置。Django filebrowser擴展配置錯誤

我把filebrowser擴展配置到根settings.py:

from django.conf import settings 

FILEBROWSER_EXTENSIONS = getattr(settings, "FILEBROWSER_EXTENSIONS", { 
    'Image': ['.jpg','.jpeg','.gif','.png','.tif','.tiff'], 
    'Document': ['.pdf','.doc','.rtf','.txt','.xls','.csv'], 
    'Video': ['.mov','.wmv','.mpeg','.mpg','.avi','.rm'], 
    'Audio': ['.mp3','.mp4','.wav','.aiff','.midi','.m4p'] 
}) 

當我嘗試啓動服務器,我得到這個錯誤:

Traceback (most recent call last): 
    File "manage.py", line 11, in <module> 
    import settings 
    File "/home/kelvin/workspace/exam/settings.py", line 177, in <module> 
    'Audio': ['.mp3','.mp4','.wav','.aiff','.midi','.m4p'] 
    File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__ 
    self._setup() 
    File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup 
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) 
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 
+1

您將該配置放入哪個settings.py文件? – Pickels 2011-04-24 09:44:49

回答

0

出現這種錯誤,如果你嘗試自己執行一個django模塊。只需將您的應用程序添加到settings.INSTALLED_APPLICATIONS中即可。 另外我想也許你正嘗試導入錯誤的設置文件, 嘗試

import filebrowser.settings 
+0

filebrowser.settings不存在。 – kelvinfix 2011-04-25 09:32:15

1

你把那個第一個代碼塊你的主要settings.py裏面?這是行不通的,因爲你實際上是在自己內部導入主設置!

+0

是的。導入其內部的設置。 – kelvinfix 2011-04-25 09:33:20