1👍
The usual way I approach this in Django is to implement the get_absolute_url()
function for the particular model class, i.e. Book
in your case.
Resulting template code would be:
{% for b in book %}
<li>
<a href="{{ b.get_absolute_url }}">{{ b.title }}</a>
</li>
{% endfor %}
Source:stackexchange.com