2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 13:56:30 +00:00

Custom list serializer for 'location_detail'

This commit is contained in:
Oliver Walters
2020-05-02 10:05:35 +10:00
parent a537b6df6e
commit 44319d24e4
3 changed files with 59 additions and 11 deletions

View File

@ -239,7 +239,7 @@ class PartList(generics.ListCreateAPIView):
cat_id = part['category']
if cat_id is not None:
category_ids.add(part['category'])
category_ids.add(cat_id)
# Fetch only the required PartCategory objects from the database
categories = PartCategory.objects.filter(pk__in=category_ids).prefetch_related(
@ -258,7 +258,7 @@ class PartList(generics.ListCreateAPIView):
cat_id = part['category']
if cat_id is not None and cat_id in category_map.keys():
detail = category_map[part['category']]
detail = category_map[cat_id]
else:
detail = None