@library.filter
def in_utc(dt):
 if (dt.utcoffset() is None):
  tz = timezone(settings.TIME_ZONE)
  dt = tz.localize(dt)
 return dt.astimezone(utc)

@ library . filter def in_utc ( dt ) : if ( dt . utcoffset ( ) is None ) : tz = timezone ( settings . TIME_ZONE ) dt = tz . localize ( dt ) return dt . astimezone ( utc )
convert a datetime to the utc timezone .