1

セットアップの最初のステップを通過できません。

これは、アプリケーションの私の 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 テストファイルブラウザ

次のエラーが表示されます。

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'...
4

1 に答える 1

1

変数のMEDIA_ROOT末尾にはスラッシュが必要です。

django-filebrowser設定ファイルからのコメントとその下の 1 行

# DO NOT USE A SLASH AT THE BEGINNING, DO NOT FORGET THE TRAILING SLASH AT THE END.
DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')

スクリプトが失敗する設定テストからの2 行

# Check for trailing slash
self.assertEqual(os.path.basename(DIRECTORY), '')
于 2013-09-14T20:34:41.033 に答える