Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@register.filter
def is_new(added, days=7):
days_new_deadline = timezone.now() - timezone.timedelta(days=days)
return added > days_new_deadline
# use in template
<a {% with obj.added|is_new as is_new %}
{% if is_new %}class="is_new newLeft"{% endif %}
{% endwith %} href="{% url 'app:view' pk %}">link</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.