[Fixed]-Why is the variable set using the django 'with' tag broken into individual strings when using it in a template provided by the include tag?

1👍

I think you might be missing some quotation marks around your templated {{my_var}} – change to "{{my_var}}".

0👍

You can pass arguments to include like this:

{% include "emp/regfield.html" with field=form.username my_var="Must be at least 4 characters long." %}

and get rid of the with wrapper statements. Just use include.

👤nik_m

Leave a comment