Model name of objects in django templates

前端 未结 5 1580
遥遥无期
遥遥无期 2020-12-09 07:59

Is there any way to get the model name of any objects in django templates. Manually, we can try it by defining methods in models or using template tags... But is there any b

5条回答
  •  遥遥无期
    2020-12-09 08:07

    You can very easily access the content type of the page, this way you don't even need to poke into the specific:

    {% if pub.content_type.app_labeled_name == 'home | publication' %}
        {% include "home/publication.html" with pub=pub.specific %}
    {% endif %}
    

提交回复
热议问题