Commit e2b5cef5 by Carlton Gibson Committed by GitHub

Merge pull request #5398 from dolphinigle/master

Fixed the MultipleFieldLookupMixin example to properly check for object level permission
parents 71ad99e0 b11f37ea
...@@ -330,7 +330,9 @@ For example, if you need to lookup objects based on multiple fields in the URL c ...@@ -330,7 +330,9 @@ For example, if you need to lookup objects based on multiple fields in the URL c
for field in self.lookup_fields: for field in self.lookup_fields:
if self.kwargs[field]: # Ignore empty fields. if self.kwargs[field]: # Ignore empty fields.
filter[field] = self.kwargs[field] filter[field] = self.kwargs[field]
return get_object_or_404(queryset, **filter) # Lookup the object obj = get_object_or_404(queryset, **filter) # Lookup the object
self.check_object_permissions(self.request, obj)
return obj
You can then simply apply this mixin to a view or viewset anytime you need to apply the custom behavior. You can then simply apply this mixin to a view or viewset anytime you need to apply the custom behavior.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment