def get_serializer_context(self): context = super(TempalteResourceView, self).get_serializer_context() self.slz = ResourceRequstSLZ( data=self.request.GET, context={'project_kind': self.project_kind}) self.slz.is_valid(raise_exception=True) context.update(self.slz.data) return context
class TempalteResourceView(generics.RetrieveAPIView): serializer_class = ResourceSLZ renderer_classes = (BKAPIRenderer, BrowsableAPIRenderer) def get_queryset(self): return VersionedEntity.objects.filter(id=self.pk) def get_serializer_context(self): context = super(TempalteResourceView, self).get_serializer_context() self.slz = ResourceRequstSLZ( data=self.request.GET, context={'project_kind': self.project_kind}) self.slz.is_valid(raise_exception=True) context.update(self.slz.data) return context def get(self, request, project_id, pk): self.pk = pk self.project_kind = request.project.kind return super(TempalteResourceView, self).get(self, request)