【问题标题】:ImportError: No module named 'filebrowser'ImportError:没有名为“文件浏览器”的模块
【发布时间】:2018-02-21 15:41:47
【问题描述】:

我刚刚在 pythonanywhere 上托管的 django 站点上安装了 django-filebrowser,并使用了 python 3.5 和 django 1.11.7。我按照文档中的说明进行设置。这些应用程序安装在 settings.py 中,我使用 manage.py collectstatic 将这些文件收集到当前位置(我使用 whitenoise 通过 Amazon CDN 提供静态文件)。

我的 urls.py 声明如下:

url(r'^filebrowser/', include('filebrowser.urls')),
url(r'^grappelli/', include('grappelli.urls')),
url(r'^admin/', admin.site.urls),

我也使用了 site.urls,但被告知“站点”未定义。

我收到的当前设置错误是:

ImportError: No module named 'filebrowser.urls'

编辑:

我还应该注意,如果我将网址更改为“app.urls”而不是“filebrowser.urls”,则该网站通常会加载,但我尝试加载文件浏览器的页面(用于提交博客文章的表单),出现此错误:

NoReverseMatch: 'filebrowser' is not a registered namespace

【问题讨论】:

  • 你是如何安装 django-filebrowser 模块的?
  • 您是否激活了正确的虚拟环境?
  • 是的,我激活了虚拟环境,我用pip install安装了。
  • 你的电脑上是否安装了其他版本的python?
  • 不,我在这台机器上只使用python 3.5。

标签: python django django-filebrowser


【解决方案1】:

您的网址看起来与docs 中的不同:

from filebrowser.sites import site

urlpatterns = [
   url(r'^admin/filebrowser/', include(site.urls)),
   url(r'^grappelli/', include('grappelli.urls')),
   url(r'^admin/', include(admin.site.urls)),
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-11
    • 2016-01-24
    • 2012-12-07
    • 2012-05-23
    • 2019-07-29
    • 2015-07-04
    • 2014-03-15
    • 2017-12-29
    相关资源
    最近更新 更多