diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5ce768171..cf7e692e5 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -379,7 +379,8 @@ class HyperlinkedIdentityField(Field): A field that represents the model's identity using a hyperlink. """ def __init__(self, *args, **kwargs): - # TODO: Make this mandatory + # TODO: Make this mandatory, and have the HyperlinkedModelSerializer + # set it on-the-fly self.view_name = kwargs.pop('view_name', None) super(HyperlinkedIdentityField, self).__init__(*args, **kwargs) diff --git a/rest_framework/tests/decorators.py b/rest_framework/tests/decorators.py index a3217bd68..41864d71e 100644 --- a/rest_framework/tests/decorators.py +++ b/rest_framework/tests/decorators.py @@ -49,6 +49,20 @@ class DecoratorTestCase(TestCase): response = view(request) self.assertEqual(response.status_code, 405) + def test_calling_put_method(self): + + @api_view(['GET', 'PUT']) + def view(request): + return Response({}) + + request = self.factory.put('/') + response = view(request) + self.assertEqual(response.status_code, 200) + + request = self.factory.post('/') + response = view(request) + self.assertEqual(response.status_code, 405) + def test_renderer_classes(self): @api_view(['GET'])