Next step is to setup an individual item page. This tutorial is giving me a some good insights into the Critique Wheel rewrite. Ideas are percolating, and questions about testing and deploying are scratching at the back of my neck. Patience.

Individual Item Page#

First step with a new page, add it to the app’s views.py.

def detail(request, detail_id):
    detail = Listings.objects.get(id=detail_id)
    context = {'detail': detail}
    return render(request, 'listings/detail.html', context)

Note to self: context is a dictionary of values passed to the template.

The urls.py additional line is:

path('my_listings/', views.my_listings, name='my_listings')

And the template key part:

for my_listing in my_listings %}
<tr>
	<td>{{ my_listing.title }}</td>
	<td>{{ my_listing.list_date }}</td>
	<td><a class="btn" href="{% url 'listings:detail' my_listing.id %}">View</a></td>
	<td></td>
	<td><a class="btn" href="">Edit</a></td>
	<td><a class="btn" href="">Delete</a></td>
</tr>
{% endfor %}

This gives a list of all items, once users are setup this list can be filtered by user item.