我正在使用django rest框架。我需要傳遞一些額外的上下文值作爲響應,但不會得到extra_value的響應。包括額外的上下文值django rest框架
class ResultRowView(generics.ListAPIView):
serializer_class = ResultRowSerializer
permission_classes = (AccountPermission,)
def get_serializer(self, *args, **kwargs):
context = {'extra_value': 5000}
return self.serializer_class(*args, context=context, **kwargs)
def get_queryset(self):
qs = ResultRow.objects.none()
pk = self.kwargs.get('pk', None)
try:
route = IncomingRoute.objects.get(account=self.request.user.account, pk=pk)
qs = route.app_module.rows.all()
except Exception, e:
print 'result_row_query: ', e
return qs
這裏缺少什麼?
什麼是''extra_value? – utkbansal
我需要傳遞一個額外的上下文值,並假設它的值是5000. –