0

我完全按照这里所说的做了:http : //readthedocs.org/docs/django-filebrowser/en/latest/quickstart.html#quickstart(仅使用easy_install而不是pip)

尝试连接到管理界面时似乎出现导入错误:

Request Method:     GET
Request URL:    http://localhost:8000/admin/
Django Version:     1.3
Exception Type:     ImportError
Exception Value:    

No module named sites

Exception Location:     c:\workspace\expedeat\..\expedeat\urls.py in <module>, line 5
Python Executable:  c:\Tools\Python26\python.exe
Python Version:     2.6.4

异常来自的导入是:from filebrowser.sites import site在 urls.py

测试文件浏览器也失败并显示此消息:

Creating test database for alias 'default'...
.......F......
======================================================================
FAIL: test_directory (filebrowser.tests.settings.SettingsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Tools\Python26\lib\site-packages\django_filebrowser-3.3.0-py2.6.egg\filebrowser\tests\set
tings.py", line 29, in test_directory
    self.assertEqual(os.path.exists(os.path.join(MEDIA_ROOT,DIRECTORY)), 1)
AssertionError: False != 1

----------------------------------------------------------------------
Ran 14 tests in 0.008s

FAILED (failures=1)
Destroying test database for alias 'default'...

我一定做错了什么。任何帮助,将不胜感激。

4

3 回答 3

5

the sites.py module does not exist in version you are using, so the error message is correct.

the installation doc you are using is for version 3.4. The pip install is 3.3. The difference being in the urls.py

3.4

from filebrowser.sites import site
urlpatterns = patterns('',
   url(r'^admin/filebrowser/', include(site.urls)),
)

3.3

urlpatterns = patterns('',
    (r'^admin/filebrowser/', include('filebrowser.urls')),
)
于 2011-09-23T08:41:21.177 回答
3

测试失败,因为它正在寻找一个不存在的目录。

要找出它要查找的目录,请执行以下操作:

% python ./manage.py shell 
>>> from django.conf import settings 
>>> import filebrowser.settings 
>>> filebrowser.settings.MEDIA_ROOT
'/srv/repositories/project/media'
>>> filebrowser.settings.DIRECTORY 
'uploads/'

根据输出,您知道它在寻找哪个目录,在本例中是 /srv/repositories/project/media/uploads。创建目录,您应该更进一步。

于 2011-10-29T20:02:43.763 回答
2

使用“FILEBROWSER_”前缀,您可以为文件浏览器应用程序提供配置。

我在我的 settings.py 中使用以下内容:

FILEBROWSER_DIRECTORY = MEDIA_ROOT
于 2011-11-29T15:59:02.663 回答