templatetag. : , templatetags , __init__.py. templatetag timestamp_to_time.py.
, , templatetag, INSTALLED_APPS.
from django import template
register = template.Library()
@register.filter('timestamp_to_time')
def convert_timestamp_to_time(timestamp):
import time
return datetime.date.fromtimestamp(int(timestamp))
:
{{ value|timestamp_to_time|date:"jS N, Y" }}
{# , format , #}
templatetag
{% load timestamp_to_time %}