[Answer]-Using {%with to define a url in django

1👍

You don’t need use with in this case, because url allow syntax {% url … as var %}, so in your case:

{% url 'pro_img_next_page' name|encode_url  images.next_page_number as href %}

Some caveats:

  • The scope of the variable created by the as var syntax is the {% block %} in which the {% url %} tag appears
  • This {% url … as var %} syntax will not cause an error if the view is missing.

Leave a comment