The variables you pass in the dictionary render_to_response are variables that fall into the template. So in detail you need to add something like {'listing': MyModel.objects.get(id=vinumber)} , and then the template should say {{ listing.id }} . But, if the identifier does not exist, it will be broken, so it is better to use get_object_or_404 .
In addition, your template goes through object_list , but the view goes through listings - one of them should be different from what you said if it works at the moment.
In addition, you should use the {% url %} tag and / or get_absolute_url on your models: instead of saying href="{{ listing.id }}" directly, let's say something like href="{% url listing-details listing.id %}" , where listing-details is the name of the view in urls.py Better yet, add the get_absolute_url function to your model with the permalink decorator ; then you can just say href="{{ listing.get_absolute_url }}" , which makes it easy to change the structure of the URL to look better or use some attribute other than the database identifier.
source share