Django 无法通过 urls.py 配置找到 djangular/app.js 文件。如何排除故障?

Django cannot find the djangular/app.js file via the urls.py config. How to troubleshoot?

我花了几天时间试图解决这个问题,但它让我感到困惑。我能复制和粘贴的内容有限,所以请原谅 'code brevity'。我也有一个我开发的工作版本并将其上传到 GitHub.

我正在开发一个也使用 AngularJS 的 Django 网站,所以我使用的 djangular package, specifically the bit that lets me import Django variables into Angular. This 是来自 GitHub:

的部分

To use the AngularJS module that Djangular provides you, you'll need to add the djangular app to your projects URLs.

 urlpatterns = patterns('',
      ...
      url(r'^djangular/', include('djangular.urls')),
      ...
  )

我已将其放入我的 project/urls.py 文件中。我对我的 GitHub 存储库做了同样的事情。

当我在 appName/app/index.html 中引用 URL 时,我是这样做的:

<script src="{% static 'djangular/app.js' %}"></script>

但这会导致服务器返回 500 响应,因为 Angular 会产生 Module 'djangular' is not available! 错误。应该发生的是上面脚本标记中的 URL djangular/app.js 应该重定向到 Python site-packages 中 Djangular 文件夹内的 urls.py,然后指向 DjangularModuleTemplateView.as_view()。这似乎在我的 GitHub 版本中有效,但由于某种原因在我的本地版本中无效。

如果我的脚本标签没有 "{%static '...'%}" 部分,我仍然会得到 500,并出现相同的错误:

<script src="/djangular/app.js"></script>

我可能忽略了什么配置导致应用找不到正确的 Djangular 配置?我一直盯着这两种配置看,我的眼睛一直呆滞,我正在努力寻找任何差异。还能是什么?

如果需要回答此问题,我非常乐意提供更多详细信息。

我通过 运行ning ./manage syncdb

自己解决了这个问题

这会创建各种 tables(用户 table 和会话 table 至少),Djangular 需要这些 运行。

然后我仔细检查了我所有的 <script> imports/includes。