0

Here calling a view within another view but I can not use its result. When attempting to use that data which gives the following result in the terminal,

Response status_code=200, "text/html; charset=utf-8">

view

class CourseFilterView(ResponseViewMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
    serializer_class = CourseFilterSerializer
    queryset = Course.objects.all()


class CourseFilterListView(ResponseViewMixin, APIView):

    def get(self, request, *args, **kwargs):
        response_data = {}
        a = CourseFilterView.as_view({'get': 'list'})(request._request, *args, **kwargs)
        response_data['a'] = a
        print('a', a)

Am I following the right path? If not, give me a solution to make it better

user15361826
  • 322
  • 2
  • 13
  • What do you want to achieve by these two views ? – Amin Sep 03 '21 at 06:28
  • Does this answer your question? [Aggregate (and other annotated) fields in Django Rest Framework serializers](https://stackoverflow.com/questions/31920853/aggregate-and-other-annotated-fields-in-django-rest-framework-serializers) – Shayan Sep 03 '21 at 06:49
  • I want to assign CourseFilterView details to a variable and append it to response_data – user15361826 Sep 03 '21 at 07:01
  • Instead of invoking it just redirect that request to that view. You can use `django.shortcuts.redirect` function or `django.responses.HttpResponseRedirect` class. – berkeebal Sep 03 '21 at 14:04

0 Answers0