title: Django : How to give parameters to {% url %} tag in javascript function which will be used in FOR loop?
body: <p>I try to make a button with a javascript "location.href" property in Django ListView templates.</p>
  
  <pre><code>{% for item in object_list %} 
     &lt;div class="clear_float"&gt; 
      &lt;h2&gt;&lt;a href = "{% url 'photo:album_detail' item.id %}"&gt;{{ item.title }}&lt;/a&gt;&lt;/h2&gt;
      &amp;emsp;&lt;b&gt;&lt;i&gt;{{ item.description }}&lt;/i&gt;&lt;/b&gt; 
      &lt;p style="display:inline" class="editbutton"&gt;
      &lt;b&gt;&lt;button onclick="photoAdd()"&gt;Add Photo&lt;/button&gt;&lt;/b&gt;
      {% if item.author == request.user %}
      &lt;b&gt;&lt;button onclick="albumEdit()"&gt;Edit&lt;/button&gt;&lt;/b&gt;
      &lt;b&gt;&lt;button onclick="albumDelete()"&gt;Delete&lt;/button&gt;&lt;/b&gt;
      {% endif %}
      &lt;/p&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>And albumEdit() and albumDelete() is coded like below.</p>
  
  <pre><code>function albumEdit(){
      location.href="{% url 'photo:album_edit' object.id %}";
  }
  function albumDelete(){
      location.href="{% url 'photo:album_delete' object.id %}";
  }
  </code></pre>
  
  <p><code>{% url 'photo:album_edit' object.id %}</code> returns "photo/object.id/edit/"</p>
  
  <p>The problem is, I guess, the ListView returns object_list so the javascript function is used in FOR loop with item object.
  I tried replacing object.id with item.id but it didn't work. </p>
  
  <p>So I also tried another way to give a argument to javascript function like below.</p>
  
  <pre><code>&lt;b&gt;&lt;button onclick="albumEdit({% url 'photo:album_update' item.id %})"&gt;Edit&lt;/button&gt;&lt;/b&gt;
  </code></pre>
  
  <p>and javascript</p>
  
  <pre><code>function albumEdit(arg){
      var address = arg;
      location.href=encodeURI(address);
  }
  </code></pre>
  
  <p>Cuz I don't know much about javascript, it also didn't work.
  I will be grateful for any advice and help.</p>
  
  <p>Thank you :D</p>