Example #1
0
 def get_prep_lookup(self):
     value = self.rhs
     if hasattr(value, "_prepare"):
         raise ValueError(
             "JSONField's 'contains' lookup only works with literal values"
         )
     return JSONValue(value)
 def get_prep_lookup(self):
     value = self.rhs
     if not hasattr(value, "_prepare") and value is not None:
         if isinstance(value, (str, int, float)) and not isinstance(value, bool):
             return Value(value)
         else:
             return JSONValue(value)
     return super().get_prep_lookup()
Example #3
0
 def get_prep_lookup(self):
     if hasattr(self.rhs, "resolve_expression"):
         raise ValueError(
             "JSONField's 'in' lookup only works with literal values")
     prepared_values = []
     for rhs_value in self.rhs:
         if hasattr(rhs_value, "resolve_expression"):
             raise ValueError(
                 "JSONField's 'in' lookup only works with literal values"
             )
         else:
             rhs_value = JSONValue(rhs_value)
         prepared_values.append(rhs_value)
     return prepared_values
Example #4
0
 def get_prep_lookup(self):
     value = self.rhs
     if not hasattr(value, '_prepare') and value is not None:
         return JSONValue(value)
     return super(JSONLookupMixin, self).get_prep_lookup()
Example #5
0
 def get_prep_lookup(self):
     value = self.rhs
     if not hasattr(value, "resolve_expression") and value is not None:
         return JSONValue(value)
     return super(JSONLookupMixin, self).get_prep_lookup()
Example #6
0
 def get_prep_lookup(self):
     value = self.rhs
     if not hasattr(value, "_prepare") and value is not None:
         return JSONValue(value)
     return super().get_prep_lookup()