Skip to content

Instantly share code, notes, and snippets.

@chhantyal
Created July 23, 2013 15:55
Show Gist options
  • Save chhantyal/6063553 to your computer and use it in GitHub Desktop.
Save chhantyal/6063553 to your computer and use it in GitHub Desktop.
Get month from a month number in Django like 1 => Jan.
# in templatetags/app_tags.py
import calendar
from django import template
register = template.Library()
@register.filter
def month_name(month_number):
return calendar.month_name[month_number]
# in templates files
{% load posts_tags %}
<p>month_number|month_name</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment