Answer the question
In order to leave comments, you need to log in
How to compare an object in the list with the previous one in a template?
class Order(models.Model):
title = models.CharField()
user = models.ForeignKey(User)
views.py
class OrderListView(ListView):
model = Order
order_list.html
{% for item in order_list %}
{{item.title}} - {{item.user}}
{% endfor %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question