1👍
✅
You can’t do this with timesince
, you’ll have to do this either with a custom tag or in your view.
I would recommend to do this in your view:
def someview(request):
objs = Some.object.filter()
ctx = {}
ctx['objs'] = [] # hold your objects
for i in objs:
ctx['objs'].append((i,i.date_field < someother_obj.date_field))
return render(request, 'template.html', ctx)
In your template:
{% for obj,flag in objs %}
<tr><td {% if flag %}class="marked"{% endif %}>{{ obj }}</td></tr>
{% endfor %}
If you want to do it with a custom tag, create a template to show the row and then create an inclusion tag which has your comparison logic.
Source:stackexchange.com