mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Catch error
This commit is contained in:
parent
3a61d11f5a
commit
52242e7a00
@ -62,7 +62,11 @@ class CategoryList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
ctx = super().get_serializer_context()
|
ctx = super().get_serializer_context()
|
||||||
|
|
||||||
|
try:
|
||||||
ctx['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
ctx['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
||||||
|
except AttributeError:
|
||||||
|
# Error is thrown if the view does not have an associated request
|
||||||
|
ctx['starred_categories'] = []
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
@ -173,7 +177,11 @@ class CategoryDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
ctx = super().get_serializer_context()
|
ctx = super().get_serializer_context()
|
||||||
|
|
||||||
|
try:
|
||||||
ctx['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
ctx['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
||||||
|
except AttributeError:
|
||||||
|
# Error is thrown if the view does not have an associated request
|
||||||
|
ctx['starred_categories'] = []
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user