我跟随本教程安装django-tinymce4-litt。在本教程的末尾,有迹象表明要安装django-filebrowser。
我使用Django 2.1.1,但是即使我遵循了所有的指示,在文件浏览器安装后显示了以下消息:
文件"/var/www/html/dev/miosito/django/beautifulsite_v0.1.1/djangosite/djangosite/urls.py",第25行,在路径(‘admin/filebrowser/’,include(site.urls))中,未定义NameError: name 'site‘
这里有urls.py:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from filebrowser.sites import site #sorry I've forgot this
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('testapp.urls')), #app for my tests
path('tinymce/', include('tinymce.urls')),
path('admin/filebrowser/', include('site.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)我做错什么了?
修正后的编辑:
我把我忘记的字符串加进去了,我改正了
path('admin/filebrowser/', include(site.urls)), 使用
path('admin/filebrowser/', include('site.urls')),但现在我有了一个新的错误:
ModuleNotFoundError:没有名为‘site.urls’的模块;'site‘不是包
发布于 2018-09-23 18:54:12
尝试以下操作:(删除include)
# ...
from filebrowser.sites import site
# ...
urlpatterns = [
# ...
path('admin/filebrowser/', site.urls),
# ...
]当您遇到特定于包本身的错误时,请始终引用包正式文档。(在本例中是django-文件浏览器,尽管主要回购似乎是在django-filebrowser-no-grappelli)。博客有时很容易过时。例如,链接中的指南没有指定他们使用的Django版本。(从教程编写include的方式来看,它似乎是Django<1.9 (参考))。
如果您使用的是Django>=2,那么正式文档应该解释安装这个包的正确方法。
https://stackoverflow.com/questions/52468333
复制相似问题