Created
July 20, 2020 17:21
-
-
Save bbelderbos/41aa5690bd76510a439e0a7a5fee7fcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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