如何在django rest框架中使用django raw,但是使用INNER join,我将以下序列化了
class PcprovinciaSerializer(serializers.ModelSerializer):
class Meta:
model = Pcprovincia
fields ="__all__"
class LolViewSet(viewsets.ModelViewSet):
queryset = Pcprovincia.objects.all()
serializer_class = PcprovinciaSerializer
module = "lol"
def list(self, request, *args, **kwargs):
try:
queryset = self.queryset.raw("SELECT * FROM PCProvincia INNER JOIN PCPais ON idpais=idpais")
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
except Exception as e:
return Response({"error":str(e)})
它产生以下错误 error
我如何序列化内部联接?