I am using django rest framework for serialize the data, I came across a scenario where i have to return two different queryset result in on view, so i tried in this way but failed to get response
q1 = tbl_nt.objects.values_list('id', 'value', 'geometry')
q2 = tbl_network.objects.values_list('id', 'value', 'geometry')
Tried following methods for build queryset
queryset = (q1) | (q2)
queryset = list(q1) + list(q2)
queryset = chain(q1, q2)
queryset = list(chain(q1, q2))
One solution that comes in my mind get the union of both queryset, serialize them and send in response so i write down this code for view just testing
class SnippetList(APIView):
def get(self, request, format=None):
snippets = tbl_network.objects.all()
json = serializers.serialize('json', snippets)
return Response(json)
Now this exception is facing
'Cannot apply DjangoModelPermissions on a view that does not have .model
or .queryset
property.'
My strategy is simple i want to create list, serialize the list and send in response
So my question is how to pass response without queryset? I this approach is correct?
I have also posted question related to this problem where one solution is posted implement inheritance but i don't want to change Database table structure