Handle case where user is not specified

This commit is contained in:
Oliver 2021-11-18 23:15:40 +11:00
parent bfb32f3bf6
commit 15a0d260f8

View File

@ -72,7 +72,7 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
def get_serializer_context(self):
ctx = super().get_serializer_context()
ctx['user'] = self.request.user
ctx['user'] = getattr(self.request, 'user', None)
return ctx
@ -392,7 +392,7 @@ class StockList(generics.ListCreateAPIView):
def get_serializer_context(self):
ctx = super().get_serializer_context()
ctx['user'] = self.request.user
ctx['user'] = getattr(self.request, 'user', None)
return ctx