Reputation: 1586
I've got two html files. I want to include one in the other and then use a block statement in the second.
message.html
<div>
Hi
</div>
{% block message1 %}
{% endblock message1 %}
main.html
{% include "message.html" %}
{% block message1 %}
this is a message
{% endblock message1 %}
When main.html is rendered, the string "this is a message" doesn't show up. Do you know why?
thanks!
Upvotes: 0
Views: 75
Reputation: 538
Instead of include, use extends
like this
{% extends 'message.html' %}
{% block message1 %}
this is a message
{% endblock message1 %}
You can refer to the official docs about django template tags Built-in template tags and filters
Upvotes: 2