diff options
| author | Edmond Wong | 2013-08-30 18:03:44 -0700 |
|---|---|---|
| committer | Edmond Wong | 2013-08-30 18:03:44 -0700 |
| commit | 3063a50fc20f0bfb7308e668cf083c5ae0876dac (patch) | |
| tree | 470fe10ce87eb1b6958ba9552fd597598374e18b | |
| parent | f8101114d1ec13e296cb393b43b0ebd9618fa997 (diff) | |
| download | django-rest-framework-3063a50fc20f0bfb7308e668cf083c5ae0876dac.tar.bz2 | |
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.
| -rw-r--r-- | rest_framework/generics.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 14feed20..4d909ef1 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -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 |
