I have a viewset that I created an @action decorated function.
class StoreOffersViewSet(viewsets.ViewSet):
"""Viewset for yoga stuff."""
@action(detail=False, methods=['put'], name='yoga update')
def update_yoga(self, request):
# Get Kwargs passed
params = self.kwargs
In my urls, I have:
router = DefaultRouter(trailing_slash=True)
router.register(r'yoga', views.StoreOffersViewSet, basename='yoga')
urlpatterns = router.urls
I would like that when a user has a PUT request to site.com/yoga, my update_yoga function is called.
As it stands now, I get the following error:
{
"detail": "Method \"PUT\" not allowed."
}
My guess is that this is because for the default router, GET and POST already have the url style from the docs, https://www.django-rest-framework.org/api-guide/routers/#defaultrouter. So I am not too sure how to proceed. I am on django 3.8>