@app.template_filter('localize_dt_obj')
def localize_dt_obj(dt, tzname):
 localized_dt = timezone(tzname).localize(dt)
 return localized_dt

@ app . template_filter ( 'localize_dt_obj' ) def localize_dt_obj ( dt , tzname ) : localized_dt = timezone ( tzname ) . localize ( dt ) return localized_dt
accepts a datetime object and a timezone name .