def fix_datetime_timezone():
	"""Patch the Psycopg2 backend to set the timezone of datetime columns correctly."""
	from psycopg2.tz import FixedOffsetTimezone
	from django.db.backends.postgresql_psycopg2 import base

	def tzinfo_factory(minutes):
		if minutes == 0:
			return FixedOffsetTimezone(offset=0, name="UTC")
		else:
			return FixedOffsetTimezone(offset=minutes)

	_cursor_orig = base.DatabaseWrapper._cursor
        def _cursor(self):
		cursor = _cursor_orig(self)
		cursor.tzinfo_factory = tzinfo_factory

		return cursor
	base.DatabaseWrapper._cursor = _cursor
fix_datetime_timezone()

