2👍
✅
This Django snippet will give you a smart if tag that you can use with operators such as greater than: http://www.djangosnippets.org/snippets/1350/
EDIT: Django now includes the smart if tag, so if you’re on the latest version then you won’t need that snippet.
5👍
If you only need greater-than, you can use the following easy snippet (put it into app/templatetags/greaterthan.py):
from django import template
register = template.Library()
@register.filter
def gt(a, b):
return a > b
And in a template:
{% load greterthan %}
{% if forloop.counter|gt:10 %}...{% endif %}
- [Django]-Django admin – OneToOneField inline throws "has no ForeignKey" exception
- [Django]-Django Queryset Iterator for Ordered queryset
- [Django]-Cannot convert Django Queryset to a List
- [Django]-PIP cannot install Django inside VIrtualenv
Source:stackexchange.com