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['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
||||
try:
|
||||
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
|
||||
|
||||
@ -173,7 +177,11 @@ class CategoryDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
ctx = super().get_serializer_context()
|
||||
|
||||
ctx['starred_categories'] = [star.category for star in self.request.user.starred_categories.all()]
|
||||
try:
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user