Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django-is it possible to use template filters inside "with"?

I have a template filter called "get_data_id" that returns a value; I want to use that value as an argument for another filter called "get_data":

{% with variable_v= "x|get_data_id"  %}
    <p> {{ variable_v|get_data }} </p>
{% endwith %}

But django returns:

'with' expected at least one variable assignment

Is it possible to use template filters in "with clause" ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you have a wrong Synaxis.
In your case:

{% with variable_v=x|get_data_id %}
    <p> {{ variable_v|get_data }} </p>
{% endwith %}

Bug is – use space_letter around "=" in with clause, next bug is – use string "x|get_data_id" instead of variable and filter x|get_data_id.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading