【发布时间】:2016-04-27 10:14:07
【问题描述】:
我经常在 django 模板中使用 django-cms 做这样的事情:
{% load cms_tags %}
<a href="{% page_url 'imprint' %}">Imprint</a>
在生产中,这会静默失败,并且 href 属性为空。在开发过程中,我不得不插入 id 为“imprint”的页面,否则会出现“DoesNotExist”异常。
我该如何改善这种情况?也许我正在寻找类似的东西
{% if 'imprint'|cms_page_exists %}
...the link and stuff...
对于这个(不是很少)用例,是否有已知的最佳实践?还是大家都先用上图?
【问题讨论】:
标签: python django django-templates django-cms