there is a model books
where i want to fetch all the objects and display it to user using django templates
books=books.objects.all()
and with django template tag im able to fetch the values in the model and display them
but is there any way where django can change the variable values based on the number
for example this part :
{% for b in books %}
<tr>
<td>{{b.books_id}}</td>
</tr>
{% endfor %}
this will display all the id's
but is there any way to override this in django
Lets say
for instance ,if the b.books_id for any object is 1
then it should display something like "completed"
if its 2 then it should display something like "no"
is there any possibility to do that ??
using if or for loops in django template tags
or through views
Yes tout have if statement in Django templates (replace b.books_id by name of the objects which contains 1 or 2):