Allow OPTIONS to retrieve PUT field metadata on empty objects

This allows OPTIONS to return the PUT endpoint's object serializer metadata when the object hasn't been created yet.
This commit is contained in:
Edmond Wong 2013-08-30 18:03:44 -07:00
parent f8101114d1
commit 3063a50fc2

View File

@ -356,8 +356,13 @@ class GenericAPIView(views.APIView):
self.check_permissions(cloned_request)
# Test object permissions
if method == 'PUT':
self.get_object()
except (exceptions.APIException, PermissionDenied, Http404):
try:
self.get_object()
except Http404:
# Http404 should be acceptable and the serializer
# metadata should be populated.
pass
except (exceptions.APIException, PermissionDenied):
pass
else:
# If user has appropriate permissions for the view, include