This was the solution I found :
{{{
{% with "My title" as title %}
{% block TitleOne %}{{ title }}{% endblock TitleOne %}
{% block TitleTwo %}{{ title }}{% endblock TitleTwo %}
{% endwith %}
}}}
In a templates that extends a second one that uses the blocks TitleOne and
TitleTwo .
But it does not work. If I write it like :
{{{
{% block TitleOne %}"My title"{% endblock TitleOne %}
{% block TitleTwo %}"My title"{% endblock TitleTwo %}
}}}
It works perfectly. But of course it s not DRY. If I write it like :
{{{
{% with "My title" as title %}
{% block TitleOne %}"My title"{% endblock TitleOne %}
{% block TitleTwo %}{{ title }}{% endblock TitleTwo %}
{% endwith %}
}}}
Only the 1st one displays right. But not DRY as well.
Tried another way suggested in Django's docs :
https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#with
{{{
{% with title="My title" %}
{% block TitleOne %}"My title"{% endblock TitleOne %}
{% block TitleTwo %}{{ title }}{% endblock TitleTwo %}
{% endwith %}
}}}
Only the 1st one displayed too..
(I am using Django 2.2.1, Python 3.7.3)
--
Ticket URL: <https://code.djangoproject.com/ticket/30539>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* ui_ux: 1 => 0
* resolution: => worksforme
* version: 2.2 => master
Comment:
Thanks for the report, however I cannot reproduce your issue. In all
described cases everything works for me.
--
Ticket URL: <https://code.djangoproject.com/ticket/30539#comment:1>