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) self.check_permissions(cloned_request)
# Test object permissions # Test object permissions
if method == 'PUT': if method == 'PUT':
try:
self.get_object() self.get_object()
except (exceptions.APIException, PermissionDenied, Http404): except Http404:
# Http404 should be acceptable and the serializer
# metadata should be populated.
pass
except (exceptions.APIException, PermissionDenied):
pass pass
else: else:
# If user has appropriate permissions for the view, include # If user has appropriate permissions for the view, include