[Answered ]-How to properly add template tags to a django project

2👍

/profiles/templatetags/custom_tags.py

@register.filter(name='getLocalTimeDifference')
def getLocalTimeDifference(value):
    value = value.replace(..)
    return value

/profiles/templates/navbar.html

{% load custom_tags %}
...

<div class="notification-meta">
    <small class="timestamp">{{ notification.timesince | getLocalTimeDifference}} before </small>
</div>

P.S. __init_.py should also be added to templatetags directory

Leave a comment