我无法通过第一步,设置它。
这是我的应用程序的settings.py:
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/django/ristoturisto/media'
FILEBROWSER_DIRECTORY = ''
STATIC_ROOT = '/home/django/ristoturisto/static'
STATIC_URL = '/static/'
FILEBROWSER_DIRECTORY = MEDIA_ROOT
文件夹存在,我从pwd复制了名称。
我确实收集了静电,这很有效。
但是当我这样做时:
python manage.py test filebrowser
我得到了以下错误:
Creating Test for the FileBrowser site: filebrowser
Creating test database for alias 'default'...
...........F......ERemoving left-over tmp dir: /home/django/ristoturisto/media/tmp_test_0
======================================================================
ERROR: runTest (filebrowser.tests.sites.TestSite_filebrowser)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/filebrowser/tests/sites.py", line 236, in runTest
test_do_upload(self)
File "/usr/lib/python2.6/site-packages/filebrowser/tests/sites.py", line 99, in test_do_upload
response = test.c.post(url, data=f.read(), content_type='application/octet-stream', HTTP_X_REQUESTED_WITH='XMLHttpRequest', X_File_Name='testimage.jpg')
File "/usr/lib/python2.6/site-packages/django/test/client.py", line 449, in post
response = super(Client, self).post(path, data=data, content_type=content_type, **extra)
File "/usr/lib/python2.6/site-packages/django/test/client.py", line 262, in post
return self.request(**r)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/views/decorators.py", line 16, in _checklogin
return view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 77, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/filebrowser/sites.py", line 476, in _upload_file
file_already_exists = self.storage.exists(file_name)
File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 230, in exists
return os.path.exists(self.path(name))
File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 246, in path
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
SuspiciousOperation: Attempted access to '/tmp_test_0/testimage.jpg' denied.
======================================================================
FAIL: test_directory (filebrowser.tests.settings.SettingsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/filebrowser/tests/settings.py", line 31, in test_directory
self.assertEqual(os.path.basename(DIRECTORY), '')
AssertionError: 'media' != ''
----------------------------------------------------------------------
Ran 19 tests in 3.810s
FAILED (failures=1, errors=1)
Destroying test database for alias 'default'...
答案 0 :(得分:1)
变量MEDIA_ROOT
最后必须有斜杠。
Comment以及django-filebrowser设置文件
下面的一行# DO NOT USE A SLASH AT THE BEGINNING, DO NOT FORGET THE TRAILING SLASH AT THE END.
DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')
来自设置测试的Two lines脚本失败
# Check for trailing slash
self.assertEqual(os.path.basename(DIRECTORY), '')