@register.simple_tag
def format_date_range(date_from, date_to, separator=' - ', format_str='{dt:%B} {dt.day}, {dt:%Y}', year_f=', {dt:%Y}', month_f='{dt:%B}'):
 if (isinstance(date_to, datetime.datetime) and isinstance(date_from, datetime.datetime)):
  date_to = date_to.date()
  date_from = date_from.date()
 if (date_to and (date_to != date_from)):
  from_format = to_format = format_str
  if (date_from.year == date_to.year):
   from_format = from_format.replace(year_f, '')
   if (date_from.month == date_to.month):
    to_format = to_format.replace(month_f, '')
  return separator.join((from_format.format(dt=date_from), to_format.format(dt=date_to)))
 return format_str.format(dt=date_from)

@ register . simple_tag def format_date_range ( date_from , date_to , separator = ' - ' , format_str = '{dt:%B} {dt.day}, {dt:%Y}' , year_f = ', {dt:%Y}' , month_f = '{dt:%B}' ) : if ( isinstance ( date_to , datetime . datetime ) and isinstance ( date_from , datetime . datetime ) ) : date_to = date_to . date ( ) date_from = date_from . date ( ) if ( date_to and ( date_to != date_from ) ) : from_format = to_format = format_str if ( date_from . year == date_to . year ) : from_format = from_format . replace ( year_f , '' ) if ( date_from . month == date_to . month ) : to_format = to_format . replace ( month_f , '' ) return separator . join ( ( from_format . format ( dt = date_from ) , to_format . format ( dt = date_to ) ) ) return format_str . format ( dt = date_from )
takes a start date .