I'd like to POST to a detail route on my Viewset:
class FooViewSet(
mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet
):
permission_classes = [IsAuthenticated]
queryset = models.Foo.active_objects.all()
serializer_class = serializers.FooSerializer
@action(
methods=["post"],
detail=True,
permission_classes=[IsAuthenticated],
url_path="",
url_name="purchase",
)
def do_foobar(self, request, pk=None):
pass
EG: POST /foo/<fooID>/
I'm aware that ViewSets allow for the @action decorator:
@action( methods=["post"], detail=True, permission_classes=[IsAuthenticated], url_path="", url_name="foo", )This however doesn't seem to allow the `url_path` field to be blank, so for example this works:
@action( methods=["post"], detail=True, permission_classes=[IsAuthenticated], url_path="foo", url_name="foo", )But then requires my API to be structured like
POST /store/<storeID>/fooIs there a way to use an empty `url_path`? because just putting an empty string doesn't work.