          # single quotes are used because this is a string (and could otherwise
          # cause a collision with a field name).
          return "django_time_trunc('%s', %s)" % (lookup_type.lower(), field_name)
  
      def datetime_cast_date_sql(self, field_name, tzname):
          return "django_datetime_cast_date(%s, %s)" % (
              field_name, self._convert_tzname_to_sql(tzname),
          )
  
 
</s> remove         return "django_datetime_cast_date(%s, %%s)" % field_name, [tzname]
 </s> add         return "django_datetime_cast_date(%s, %s)" % (
            field_name, self._convert_tzname_to_sql(tzname),
        ) </s> remove         return "django_datetime_trunc('%s', %s, %%s)" % (
            lookup_type.lower(), field_name), [tzname]
 </s> add         return "django_datetime_trunc('%s', %s, %s)" % (
            lookup_type.lower(), field_name, self._convert_tzname_to_sql(tzname),
        ) </s> remove         return "django_datetime_cast_time(%s, %%s)" % field_name, [tzname]
 </s> add         return "django_datetime_cast_time(%s, %s)" % (
            field_name, self._convert_tzname_to_sql(tzname),
        ) </s> remove         return "django_datetime_extract('%s', %s, %%s)" % (
            lookup_type.lower(), field_name), [tzname]
 </s> add         return "django_datetime_extract('%s', %s, %s)" % (
            lookup_type.lower(), field_name, self._convert_tzname_to_sql(tzname),
        ) </s> remove         sql = 'TRUNC(%s)' % field_name
        return sql, []
 </s> add         return 'TRUNC(%s)' % field_name
    def _convert_tzname_to_sql(self, tzname):
        return "'%s'" % tzname if settings.USE_TZ else 'NULL'

          # single quotes are used because this is a string (and could otherwise
          # cause a collision with a field name).
          return "django_time_trunc('%s', %s)" % (lookup_type.lower(), field_name)
  
    def _convert_tzname_to_sql(self, tzname):
        return "'%s'" % tzname if settings.USE_TZ else 'NULL'

      def datetime_cast_date_sql(self, field_name, tzname):
          return "django_datetime_cast_date(%s, %s)" % (
              field_name, self._convert_tzname_to_sql(tzname),
          )
  
keep keep keep add keep keep keep keep keep
 Fixed #27802 -- Unified return value of db backend datetime SQL methods. 
django/db/backends/sqlite3/operations.py