我正在编写小型 django 应用程序,它允许用户使用安装了 django-tinymce 的 tinymce 编辑器发布消息。一切正常,但是当我尝试添加 django-filebrowser 来安装应用程序时,tinymce 小部件从帖子表单中消失了。我已经安装了 grappelli 和 PIL 库。它适用于 /admin/filebrowser/browse。我可以上传文件,但缩略图不显示。Django-filebrowser 无法通过测试:
python2.6 manage.py test filebrowser
Creating Test for the FileBrowser site: filebrowser
Creating test database for alias 'default'...
..................uploads/tmp_test_0/testimage_medium.jpg
FRemoving left-over tmp dir: uploads/tmp_test_0
======================================================================
FAIL: runTest (filebrowser.tests.sites.TestSite_filebrowser)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/filebrowser/tests/
sites.py", line 233, in runTest
test_detail(self)
File "/usr/local/lib/python2.6/dist-packages/filebrowser/tests/
sites.py", line 140, in test_detail
test.assertTrue(test.site.storage.exists(path))
AssertionError: False is not True
----------------------------------------------------------------------
Ran 19 tests in 1.114s
FAILED (failures=1)
Destroying test database for alias 'default'...
我正在使用 filebroswer 3.41、django-tinymce 1.5.1b2、PIL 1.1.7、grappelli 2.3.7
我的看法:
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media/')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_PATH, 'static/')
STATIC_URL = '/static/'
TINYMCE_JS_URL = STATIC_URL + 'tiny_mce/tiny_mce.js'
TINYMCE_DEFAULT_CONFIG = {'theme': "advanced", }
TINYMCE_FILEBROWSER = True
# Filebrowser
FILEBROWSER_MEDIA_ROOT = MEDIA_ROOT
FILEBROWSER_MEDIA_URL = MEDIA_URL
FILEBROWSER_STATIC_ROOT = STATIC_ROOT
FILEBROWSER_STATIC_URL = STATIC_URL
URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/'
PATH_FILEBROWSER_MEDIA = STATIC_ROOT + 'filebrowser/'
URL_TINYMCE = STATIC_URL + 'tiny_mce/'
PATH_TINYMCE = STATIC_ROOT + 'tiny_mce/'
tinymce 文件位于 /mainprojectfolder/static/tiny_mce/tiny_mce.js
网址.py:
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/filebrowser/', include(site.urls)), name='tinymce-filebrowser'),
(r'baza/', include('projekt.baza.urls')),
(r'^grappelli/', include('grappelli.urls')),
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes':True}),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes':True}),
我怎样才能让它工作?