Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Tag inside a Template tag

Tags:

python

django

So I'm using the django-jcrop plugin to crop an image. Inside my HTML file I have this line:

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

When this is passed, I get the following error:

TemplateSyntaxError: max_size must match INTxINT

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

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

So I am pretty sure ratio is not parsing correctly within the tag. Any ideas why?

like image 580
pepper5319 Avatar asked Mar 30 '17 23:03

pepper5319


1 Answers

inside a template tag you don't need to use the "{{}}", you can try the next code:

<img src="{% cropped_thumbnail order 'cropping' max_size=ratio %}">
like image 125
Nazkter Avatar answered Sep 24 '22 10:09

Nazkter