两个url和url标签引用的视图
我在模板中使用 url
标签作为视图,该视图由两个不同的 url 使用。我在一处得到错误的网址。有没有办法强制 django 检索不同的 url?为什么它不通知我,发生了这样的冲突,并且它不知道该怎么做(因为 python zen 说,那就应该拒绝猜测的诱惑)。
模板中的代码:
{% url djangoldap.views.FilterEntriesResponse Entry=entry.path as filter_url %}
url 中的代码:
(r'^filter_entries/(?P<Entry>.*)/$',
'djangoldap.views.FilterEntriesResponse',
{'filter_template': 'filter_entries.html',
'results_template': 'filter_results.html'}),
(r'^choose_entries/(?P<Entry>.*)/$',
'djangoldap.views.FilterEntriesResponse',
{'filter_template': 'search_entries.html',
'results_template': 'search_results.html'}),
如您所见,这两个 url 使用相同的视图,但使用不同的模板。我如何强制 django 检索前一个 url,而不是后者?
I am using url
tag in my template for a view, that is used by two different urls. I am getting the wrong url in one place. Is there any way to force django to retrieve different url? Why it doesn't notify my, that such conflict occured and it doesn't know what to do (since python zen says, that is should refuse temptation to guess).
Code in template:
{% url djangoldap.views.FilterEntriesResponse Entry=entry.path as filter_url %}
Code in urls:
(r'^filter_entries/(?P<Entry>.*)/
As you can see, those two urls use the same view, but with different templates. How I can force django to retrieve former url, rather than latter?
,
'djangoldap.views.FilterEntriesResponse',
{'filter_template': 'filter_entries.html',
'results_template': 'filter_results.html'}),
(r'^choose_entries/(?P<Entry>.*)/
As you can see, those two urls use the same view, but with different templates. How I can force django to retrieve former url, rather than latter?
,
'djangoldap.views.FilterEntriesResponse',
{'filter_template': 'search_entries.html',
'results_template': 'search_results.html'}),
As you can see, those two urls use the same view, but with different templates. How I can force django to retrieve former url, rather than latter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过向元组中添加另一个项目来命名您的 URL:
然后您可以在 URL 标记。
Name your URLs by adding another item to the tuple:
Then you can use the name in the URL tag.