Django string combination inside template label itself

I'm trying to concatenate some lines to format the url inside my template tag, but I don't find it elegant.

So far I have:

{% button "Activate" "http://" site.domain url 'registration_activate' activation_key %} 

Is there any good practice to make it more readable?

Thank you so much

+8
django django-templates
source share
2 answers

What I use when I want to concatenate strings in Django templates from variables (examples taken from my own code, tell me if you need something closer to your case):

 <html> <input id="myid_{{idBase}}_{{idFinal}}" type="checkbox"></input> </html> 

and inside the django tag I use the keyword "add" associated with keywork with

 {% with 'images/'|add:file_name as image_static %} <img src="{% static image_static %}" title = "{{ tooltip }}" alt = "{{ title }}"/> {% endwith %} 
+5
source share

You can concatenate two lines in a Django template as follows:

 {{"First String "|add:"Second String"}} 

Just replace the two lines with your own variable.

+5
source share

All Articles