Skip to content

Commit f752f40

Browse files
committed
http_method_names that are specific to the view flavors
1 parent 7dab083 commit f752f40

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

example/tests/integration/test_polymorphism.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def test_polymorphism_relations_update(single_company, research_project_factory,
178178

179179

180180
def test_polymorphism_relations_put_405(single_company, research_project_factory, client):
181-
# the preceding had been incorrectly using PUT instead of PATCH. This confirms PUT now fails.
182181
response = client.get(reverse("company-detail", kwargs={'pk': single_company.pk}))
183182
content = response.json()
184183
assert content["data"]["relationships"]["currentProject"]["data"]["type"] == "artProjects"

rest_framework_json_api/views.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,33 +239,25 @@ def get_related_instance(self):
239239
raise NotFound
240240

241241

242-
class ValidHTTPMethodsMixin(object):
243-
"""
244-
JSONAPI does not define methods like PUT and TRACE
245-
"""
246-
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
247-
248-
249242
class ModelViewSet(AutoPrefetchMixin,
250243
PreloadIncludesMixin,
251244
RelatedMixin,
252-
ValidHTTPMethodsMixin,
253245
viewsets.ModelViewSet):
254-
pass
246+
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
255247

256248

257249
class ReadOnlyModelViewSet(AutoPrefetchMixin,
258250
RelatedMixin,
259-
ValidHTTPMethodsMixin,
260251
viewsets.ReadOnlyModelViewSet):
261-
pass
252+
http_method_names = ['get', 'head', 'options']
262253

263254

264-
class RelationshipView(ValidHTTPMethodsMixin, generics.GenericAPIView):
255+
class RelationshipView(generics.GenericAPIView):
265256
serializer_class = ResourceIdentifierObjectSerializer
266257
self_link_view_name = None
267258
related_link_view_name = None
268259
field_name_mapping = {}
260+
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
269261

270262
def get_serializer_class(self):
271263
if getattr(self, 'action', False) is None:

0 commit comments

Comments
 (0)