django-filebrowser返回系统路径而不是媒体URL

时间:2015-03-05 19:49:29

标签: django django-filebrowser

Tests: OK
Version: FileBrowser 3.5.7, Grappelli 2.5.3, Django 1.6.10

Filebrowser呈现奇怪的图片网址。例如,/admin/filebrowser/browse/呈现:

<td class="fb_thumbnail">            
    <a href="/Users/mike/Projects/oi/adx/public/media/0b8d1ac8bb874a16c292260348065e3c.jpg" class="fb_viewlink"><img src="/Users/mike/Projects/oi/adx/public/media/_versions/0b8d1ac8bb874a16c292260348065e3c_admin_thumbnail.jpg" title="View Image"></a>            
</td>

它创建缩略图,但由于某种原因,URL是文件路径。

我的设置:

DEFAULT_FILE_STORAGE= 'django.core.files.storage.FileSystemStorage'
FILEBROWSER_DIRECTORY = '/Users/mike/Projects/oi/adx/public/media/'
FILEBROWSER_MEDIA_ROOT = '/Users/mike/Projects/oi/adx/public/media/'
FILEBROWSER_MEDIA_URL = '/media/'
FILEBROWSER_VERSIONS_BASEDIR = '/Users/mike/Projects/oi/adx/public/media/_versions'
MEDIA_ROOT = '/Users/mike/Projects/oi/adx/public/media/'
MEDIA_URL = '/media/'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = '/Users/mike/Projects/oi/adx/public/static'
STATIC_URL = '/static/'

1 个答案:

答案 0 :(得分:2)

FILEBROWSER_DIRECTORYFILEBROWSER_MEDIA_ROOT相关,因此请将其设为空:

FILEBROWSER_DIRECTORY = ''

或限制某些目录:

FILEBROWSER_DIRECTORY = 'uploads/'

另请注意,FILEBROWSER_MEDIA_ROOTFILEBROWSER_MEDIA_URLMEDIA_ROOT / MEDIA_URL相同。这是默认设置,您可以安全地从settings.py删除这些行。