Django check block content is none or not
Can I code something like this? :
// base.html
{% block content %}
{% if block content is None %}
<p> default content </p>
{% endif %}
{% endblock content %}
// child.html
{% block content %}
<p> child content </p>
{% endblock content %}
I know I just need to code something like this:
// base.html
{% block content %}
{% endblock content %}
// child.html
{% block content %}
{% if child.content %}
<p> child content </p>
{% else %}
<p> default content </p>
{% endif %}
{% endblock content %}
But I have so many child.html inherit from base.html.. So I just want to change the parent(base.html). Is it possible?
{% extends 'base.html' %}
{% block content %}
{% endblock content %}
{% include 'child.html' %}
{% block content %}
{% if child.content %}
<p> child content </p>
{% else %}
<p> default content </p>
{% endif %}
{% endblock content %}
i belive you looking something like can we extends something multiples times this is how we do it we can use extends only once then we need to use include and give path i hope it helps you if not let me know i will improve the answer