              raise ValueError('%s is not a valid spatial lookup for %s.' %
                               (lookup_type, self.__class__.__name__))
  
      def get_prep_lookup(self, lookup_type, value):
          if lookup_type == 'isnull':
              return bool(value)
          else:
              return self.get_prep_value(value)
  
      def get_db_prep_save(self, value, connection):
          "Prepares the value for saving in the database."
          if not value:
 
</s> remove         return obj.get_compiler(connection=self.connection).as_sql()
 </s> add         return obj.get_compiler(connection=self.connection).as_sql(subquery=True)
        if lookup_type == 'contains':
            # 'contains' name might conflict with the "normal" contains lookup,
            # for which the value is not prepared, but left as-is.
              raise ValueError('%s is not a valid spatial lookup for %s.' %
                               (lookup_type, self.__class__.__name__))
  
      def get_prep_lookup(self, lookup_type, value):
        if lookup_type == 'contains':
            # 'contains' name might conflict with the "normal" contains lookup,
            # for which the value is not prepared, but left as-is.
        if lookup_type == 'contains':
            # 'contains' name might conflict with the "normal" contains lookup,
            # for which the value is not prepared, but left as-is.
        if lookup_type == 'contains':
            # 'contains' name might conflict with the "normal" contains lookup,
            # for which the value is not prepared, but left as-is.
              return self.get_prep_value(value)
  
      def get_db_prep_save(self, value, connection):
          "Prepares the value for saving in the database."
          if not value:
keep keep keep keep replace replace replace keep keep keep keep keep
 Fixed #14483 -- Allowed using subqueries with GIS lookups 
django/contrib/gis/db/models/fields.py