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

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -