Django rest framework url with suffix

Viewed 712

I have with url:

api/v1/quote/ # list
api/v1/quote/1/ # detail

how can i make new url like this:

api/v1/quote/1/action

and to send post request on this url with parametre active true, so it will use id from url and active from post and then do that action?

Any example for this?

I have this urls code:

router = routers.DefaultRouter()
router.register(r'quote', QuoteViewSet)

and view:

class QuoteViewSet(viewsets.ModelViewSet):
    queryset = Quote.active.all()
    serializer_class = QuoteSerializer

    filter_backends = (filters.OrderingFilter,)
    ordering_fields = ('created_at',)

    http_method_names = ['get', 'post', 'head']
1 Answers
Related