为什么我的urls.py不起作用?

时间:2011-03-09 01:00:49

标签: python html django templates

url(r'^video/?$','stuff.abc.views.video',name="video"),

这不起作用:

<a href="{% url video %}">Videos</a>

但这有效:

<a href="/video">Videos</a>

错误是:

TemplateSyntaxError at /
Caught ViewDoesNotExist while rendering: Tried ad in module stuff.abc.views. Error was: 'module' object has no attribute 'ad'

1 个答案:

答案 0 :(得分:3)

网址本身并没有破坏内容,而stuff.abc.views模块存在错误。

在该模块中的某个位置(可能在video视图函数中),您正在尝试访问不存在的名为ad的属性。

这个错误令人困惑,因为它说的是ViewDoesNotExist,但这真的只是让Django感到困惑,因为它预计会因为其他原因而在attribute error捕获。

相关问题