[Django]-Django templatetags ISO to date

6👍

Why not convert it to a datetime instance before passing it to the template? Then you could use the date filter in the template to output whatever you want. If you don’t/can’t do that, you’ll have to write a custom filter tag to read the isoformat date and output it how you want to.

Example using dateutil library:

from django import template
import dateutil

register = template.Library()

@register.filter(name='to_date')
def to_date(value):
    return dateutil.parser.parse(value)

Docs for custom filter tags.

Leave a comment