Django - tag inside template tag

Therefore, I use the django-jcrop to crop the image. Inside my HTML file, I have this line:

 <img src="{% cropped_thumbnail order 'cropping' max_size='{{ ratio }}' %}"> 

When this is transmitted, I get the following error:

 TemplateSyntaxError: max_size must match INTxINT 

{{ ratio }} is passed correctly outside the tag and gives the correct 400x400 value. When I remove single quotes from max_size='{{ ratio }}' , I get the following error:

 TemplateSyntaxError: Could not parse the remainder: '{{' from '{{' 

Thus, I am sure that the relation is not parsed correctly in the tag. Any ideas why?

+5
source share
1 answer

inside the template tag you do not need to use "{{}}", you can try the following code:

 <img src="{% cropped_thumbnail order 'cropping' max_size=ratio %}"> 
+1
source

Source: https://habr.com/ru/post/1266145/


All Articles