how to pass object or object id to another template
<p>I am new in Django framework.
i have a template that displays list of all objects in the database. On clicking any of the object in the list should redirect to another page that shows the object details for that particular object.
Presently i have been able to get the list of objects in the database, but not been able to forward the object id to the next template.</p>

<p>Here is my views.py</p>

<pre><code>def homepage(request):
    context = {}
    items = AddInv.objects.all()
    return render(request, "selly/homepage.html", {'items': items})

def item(request, item_id):
    context = {}
    each_item = AddInv.objects.get(pk=item_id)
    return render(request, "selly/item.html", {'each_item':each_item})
</code></pre>

<p>Here is the template that shows the all the objects</p>

<pre><code>&lt;div&gt;
    {% for product in items %}
    &lt;form method="POST" action="/selly/item/{{product.pk}}" item_id="{{product.pk}}"&gt;
        {% csrf_token %}
        &lt;td&gt;
            &lt;p&gt;&lt;a href="/selly/item/"&gt;&lt;img src="{{product.docfile.url}}" class="img-circle" width="150" height="150" align="middle"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;br&gt;* Description is : {{product.description}}
            &lt;br&gt;* Price is : {{product.price}}
            &lt;br&gt;* Quantity is : {{product.quantity}}
            &lt;br&gt;* Sold is : {{product.sold}}
            &lt;br&gt;* Total Paypent is : {{product.total_payments}}
            &lt;br&gt;* Item Remaining is : {{product.item_remaining}}
            &lt;p&gt;{{product.id}}&lt;/p&gt;
            &lt;br&gt;
            &lt;br&gt;
        &lt;/td&gt;
    &lt;/form&gt;
    {% endfor %}
&lt;/div&gt;
</code></pre>

<p>Here is the template to display the detail of a clicked object</p>

<pre><code>&lt;form method="POST" action="/selly/item/" item_id="{{product.pk}}"&gt;
    {% csrf_token %}
    &lt;p&gt;&lt;a href="/selly/item/"&gt;&lt;img src="{{product.docfile.url}}" class="img-circle" width="150" height="150" align="middle"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;Description is : {{product.description}}&lt;/p&gt;
    &lt;p&gt;Price is : {{product.price}}&lt;/p&gt;
    &lt;p&gt;Sold is : {{product.sold}}&lt;/p&gt;
    &lt;p&gt;Item Remaining is : {{product.item_remaining}}&lt;/p&gt;
    &lt;p&gt;Quantity is : &lt;input type="number" default="0"&gt;&lt;/p&gt;
    &lt;br&gt;
    &lt;input type="submit" class="btn btn-primary" value="Add to Cart"&gt;

&lt;/form&gt;
</code></pre>