How to programmatically call a Django Rest Framework view within another view?

I found the solution for this in the documentation… https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins/

Hint is from their example here:

class AuthorDetail(View):

    def get(self, request, *args, **kwargs):
        view = AuthorDisplay.as_view()
        return view(request, *args, **kwargs)

    def post(self, request, *args, **kwargs):
        view = AuthorInterest.as_view()
        return view(request, *args, **kwargs)

Leave a Comment