input type hidden value into the django template filters

438 Views Asked by At

I want to use one custom django filter. It is having 2 variable movpath and projectname. movpath is coming from input type hidden.

{% if movpath|is_path_exist:projectName %}
     do something
{% else %}
     do something
{% endif %}

Is it possible that we can take input type hidden value into the django template.

1

There are 1 best solutions below

0
On

The standard way of using templates in Django consists in passing context variables to it. Consequently

So, at some point, you should have

context = {'form': form}, 'movpath': movpath}
render("template_name.html", context)

where movpath is obtained from the form's hidden field.

This way, the value of the hidden field of the form is passed to the context, which is passed to the template during rendering.