Django Rest queryset inside APIview -


i have 2 serializers 2 models want combine 2 serializers 1 view

class productrequestview(apiview):     permission_classes = [isauthenticatedorreadonly]      def get(self, request):          city_serializer = citycompactserializer         models = modelsnestedserializer          data = {'cities':{'city data'},                 'models': {'models data'}}          return response(data, status=http_200_ok) 

i think have pass queryset both serializers data. how can inside view. new drf. ? thanks

class productrequestview(apiview):     permission_classes = [isauthenticatedorreadonly]      def get(self, request):          data = {             'cities': categorycompactserializer(<categorymodel>.objects.all(), many=true).data             'models': modelsnestedserializer(<modelsmodel>.objects.all(), many=true).data         }          return response(data, status=http_200_ok) 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -