mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Ignore empty args in the MultipleFieldLookupMixin
definition - Closes #4484
This commit is contained in:
parent
6b6f319509
commit
e91ffc87cb
|
@ -330,6 +330,7 @@ For example, if you need to lookup objects based on multiple fields in the URL c
|
|||
queryset = self.filter_queryset(queryset) # Apply any filter backends
|
||||
filter = {}
|
||||
for field in self.lookup_fields:
|
||||
if self.kwargs[field]: # Ignore empty fields.
|
||||
filter[field] = self.kwargs[field]
|
||||
return get_object_or_404(queryset, **filter) # Lookup the object
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user