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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -