Ignore empty args in the MultipleFieldLookupMixin definition - Closes #4484

This commit is contained in:
Xavier Ordoquy 2016-09-13 07:21:10 +02:00
parent 6b6f319509
commit e91ffc87cb

View File

@ -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