简体   繁体   中英

Django - Tag inside a Template tag

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?

在模板标记内,您不需要使用“{{}}”,您可以尝试下一个代码:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM