def filter_queryset(self, value, queryset): field_lookup = 'iexact' if self.ignore_case else 'exact' filter_kwargs = { 'org': self.org, '%s__%s' % (self.field_name, field_lookup): value } return qs_filter(queryset, **filter_kwargs)
def filter_queryset(self, attrs, queryset, serializer): """ Filter the queryset to all instances matching the given attributes. """ # This is a modified version of `UniqueTogetherValidator.filter_queryset`, # modifed to preprocess field names for case-insensitive matching. # It also handles filtering on soft-deletes if appropriate. # field names => field sources sources = [ serializer.fields[field_name].source for field_name in self.fields ] # If this is an update, then any unprovided field should # have its value set based on the existing instance attribute. if serializer.instance is not None: for source in sources: if source not in attrs: attrs[source] = getattr(serializer.instance, source) if hasattr(queryset, "active"): queryset = queryset.active() # Determine the filter keyword arguments and filter the queryset. filter_kwargs = { self.process_field_name(source): attrs[source] for source in sources } return qs_filter(queryset, **filter_kwargs)
def filter_queryset(self, value, queryset): """ Filter the queryset to all instances matching the given attribute. """ filter_kwargs = { '%s__%s' % (self.field_name, self.lookup): " ".join(value.split()) } return qs_filter(queryset, **filter_kwargs)
def filter_queryset(self, value, queryset, field_name): """ Filter the queryset to all instances matching the given value on the specified lookup field. """ filter_kwargs = { '%s__%s' % (self.lookup_field or field_name, self.lookup): value } return qs_filter(queryset, **filter_kwargs)
def filter_queryset(self, value, queryset): queryset = super().filter_queryset(value, queryset) return qs_filter(queryset, **{"org": self.org})
def filter_queryset(self, value, queryset): queryset = super(UniqueForOrgValidator, self).filter_queryset(value, queryset) return qs_filter(queryset, **{'org': self.org})
def filter_queryset(self, value, queryset): field_lookup = 'iexact' if self.ignore_case else 'exact' filter_kwargs = {'org': self.org, '%s__%s' % (self.field_name, field_lookup): value} return qs_filter(queryset, **filter_kwargs)
def filter_queryset(self, value, queryset): queryset = super().filter_queryset(value, queryset) return qs_filter(queryset, **{"org": self.org})