【发布时间】:2019-02-27 07:35:06
【问题描述】:
我正在关注 this tutorial 以安装 django-tinymce4-lite。在教程的最后有安装 django-filebrowser-no-grappelli 的指示。
我使用 Django 2.1.1,但即使我已遵循所有指示,在安装文件浏览器后仍显示此消息:
文件 "/var/www/html/dev/miosito/django/beautifulsite_v0.1.1/djangosite/djangosite/urls.py", 第 25 行,在 path('admin/filebrowser/', include(site.urls)), NameError: name 'site' is not defined
这里有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)
我做错了什么?
Yeo 修正后编辑:
我已经添加了我忘记的字符串并且我已经正确了
path('admin/filebrowser/', include(site.urls)),
与
path('admin/filebrowser/', include('site.urls')),
但现在我遇到了这个新错误:
ModuleNotFoundError:没有名为“site.urls”的模块; “网站”不是 包
【问题讨论】:
-
你忘了
from filebrowser.sites import site -
现在我又有一个错误
-
您为什么不按照教程进行操作?改用这个
path('admin/filebrowser/', include(site.urls)), -
如果你引用
site.urls,那么它意味着不同的东西...... -
Yeo 我已经使用了 site.urls 上的报价,但出现了这个错误:
标签: django python-3.6 django-tinymce django-filebrowser django-2.1