我对django tinymce有意见。此模块在管理面板中加载不正确,可能也是正常形式。我使用python manage.py collectstatic
收集静态文件。我正在用debug = False
运行应用程序。我有两个错误:
Failed to load resource: the server responded with a status of 404 (Not Found)
Uncaught ReferenceError: tinyMCE is not defined
您可以在screenshoot中看到错误
设置:
INSTALLED_APPS = [
'tinymce',
...
]
...
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
ENV_PATH = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(ENV_PATH, '../public/static/')
MEDIA_ROOT = os.path.join(ENV_PATH, '../public/media/')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, "tiny_mce")
TINYMCE_JS_URL = os.path.join(TINYMCE_JS_ROOT, "tiny_mce.js")
TINYMCE_DEFAULT_CONFIG = {
'height': 360,
'width': 1120,
'cleanup_on_startup': True,
'custom_undo_redo_levels': 20,
'selector': 'textarea',
'theme': 'modern',
'plugins': '''
textcolor save link image media preview codesample contextmenu
table code lists fullscreen insertdatetime nonbreaking
contextmenu directionality searchreplace wordcount visualblocks
visualchars code fullscreen autolink lists charmap print hr
anchor pagebreak
''',
'toolbar1': '''
fullscreen preview bold italic underline | fontselect,
fontsizeselect | forecolor backcolor | alignleft alignright |
aligncenter alignjustify | indent outdent | bullist numlist table |
| link image media | codesample |
''',
'toolbar2': '''
visualblocks visualchars |
charmap hr pagebreak nonbreaking anchor | code |
''',
'contextmenu': 'formats | link image',
'menubar': True,
'statusbar': True,
}
和URL:
urlpatterns = [
re_path(r'^tinymce/', include('tinymce.urls')),
...
]
编辑
我更新了代码,遵循@dirkgroten编写的指令,仍然得到了errorsHere is a tree of folderssettings.py
在pystyle dir中
对于所有静态/媒体设置,请记住:
ROOT
是文件在存储器上的物理位置。在这里,您可以使用os.path.join
之类的方法在文件系统中构建操作系统路径李>URL
是用于通过internet获取资源的url。这将由您的服务器(nginx)处理,它将把它转换为文件的实际位置,以便返回该文件李>所以你的
TINYMCE_JS_URL
错了。它不是你磁盘上的路径,而是一个URL。应该是:相关问题 更多 >
编程相关推荐