diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index dc521b42c6..b08834445c 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -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