我应该在哪里放置文件浏览器的扩展名设置。
我将filebrowser扩展配置放入root 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.
答案 0 :(得分:1)
您是否已将第一个代码块放入主settings.py中?这不起作用,因为你实际上是在自己内部导入主要设置!
答案 1 :(得分:0)
如果您尝试在其上执行一个django模块,则会出现此类错误。只需将您的应用程序添加到settings.INSTALLED_APPLICATIONS即可,这应该足够了。 或者我想也许你正试图导入错误的设置文件, 试试
import filebrowser.settings