Skip to content

Commit 629a8ad

Browse files
committed
Allow POST, PATCH, DELETE for actions in ReadOnlyModelViewSet (#797)
Currently if you try to use `POST` for action in `ReadOnlyModelViewSet` you will get problems: - with DRF UI you will loose data input forms - `drf_yasg` package will not generate OpenAPI specifications for such actions This behavior was added to `django-rest-framework-json-api` in version 2.8.0 by mistake: Commit: 7abd764 Subject: remove disallowed PUT method. (#643)
1 parent 073c45b commit 629a8ad

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Raphael Cohen <[email protected]>
1919
Roberto Barreda <[email protected]>
2020
Rohith PR <[email protected]>
2121
santiavenda <[email protected]>
22+
Sergey Kolomenkin <https://kolomenkin.com>
2223
Tim Selman <[email protected]>
2324
Yaniv Peer <[email protected]>
2425
Mohammed Ali Zubair <[email protected]>

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ any parts of the framework not mentioned in the documentation should generally b
1818

1919
* Avoid `AttributeError` for PUT and PATCH methods when using `APIView`
2020
* Clear many-to-many relationships instead of deleting related objects during PATCH on `RelationshipView`
21+
* Allow POST, PATCH, DELETE for actions in `ReadOnlyModelViewSet`. It was problematic since 2.8.0.
2122

2223
### Changed
2324

rest_framework_json_api/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class ModelViewSet(AutoPrefetchMixin,
210210
class ReadOnlyModelViewSet(AutoPrefetchMixin,
211211
RelatedMixin,
212212
viewsets.ReadOnlyModelViewSet):
213-
http_method_names = ['get', 'head', 'options']
213+
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
214214

215215

216216
class RelationshipView(generics.GenericAPIView):

0 commit comments

Comments
 (0)