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
Post a Comment