python - Link to a page in django cms, first check if it exists -
i things in django template, django-cms:
{% load cms_tags %} <a href="{% page_url 'imprint' %}">imprint</a>
on production, fails silently, , href attribute empty. on development, i'm forced insert page id "imprint", otherwise "doesnotexist" exception.
how can improve situation? maybe i'm looking like
{% if 'imprint'|cms_page_exists %} ...the link , stuff...
is there known best practice (not quite seldom) use case? or use shown first?
you assign tag result variable , check empty:
{% page_url 'imprint' url %} {% if url %} <a href="{{ url }}">imprint</a> {% endif %}
other ways imply creating own template tag or filters, above simplest 1 imho. see example in docs.
Comments
Post a Comment