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

前端 未结 5 1393
醉酒成梦
醉酒成梦 2020-12-04 17:38

I have the following generic class based views built with Django Rest framework (DRF)

class ExampleDetail(generics.RetrieveUpdateDestroyAPIView):
    queryse         


        
5条回答
  •  情话喂你
    2020-12-04 18:19

    I found the solution for this in the documentation... https://docs.djangoproject.com/en/1.7/topics/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)
    

提交回复
热议问题