python – Django template nested tags


I include another template in the template by specifying a set of variables, including the link (action):

{% include "ssn/block_form_as_table.html" with form=form action='ssn:hoster_server_create_action' submit_title='Create a server' %}

Now I needed to pass a link with a parameter as a variable. How can I do the following:

{% include "ssn/block_form_as_table.html" with form=form action={% url 'ssn:hoster_server_edit_action' %} submit_title='Save a server' %}

I face the same problem when I want to transfer to submit_title not just the text Create a server , but {% trans 'Create a server' %} .

In general, how can I use the result of other tags in the parameters of tags?


You can do this:

{% url 'ssn:hoster_server_edit_action' as some_url %}
{% trans 'Create a server' as some_trans %}
{% include "ssn/block_form_as_table.html" with form=form action=some_url submit_title=some_trans %}

Well, or in general, pass variables through the view and use them in a pluggable template.

Scroll to Top