1👍
✅
The best way to solve this is probably to make sure that views which use the template just use the same variable name.
If that’s not possible I’d do this instead:
{% if list_of_books or search_results %}
<table border="0" align="left" width="70%">
{% if search_results %}
{% include "book_listing.html" with books=search_results %}
{% else %}
{% include "book_listing.html" with books=list_of_books %}
{% endif %}
</table>
{% else %}
<p>No Books available.</p>
{% endif %}
And then put this in book_listing.html
:
{% for book in books %}
<tr>
<td>
<a href="{{ book.get_absolute_url }}">{{ book.title }}</a>
</td>
</tr>
{% endfor %}
0👍
<span>
{%if booking.DiscountedFare == booking.TotalFare %}
Rs.{{ booking.TotalFare }}
{% else %}
Rs.{{ booking.DiscountedFare }}
{% endif %}
</span>
- [Answer]-Django deployment https + gunicorn and nginx
- [Answer]-Trying to access Postgres function from django
- [Answer]-Encoding in Django admin
- [Answer]-Django stopped working with mod_wsgi/apache
- [Answer]-Django Tutorial: Where does the other objects come from?
Source:stackexchange.com