From 3d9a1acc2ec2ee0067000b8951ec70beed42254f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 15 Apr 2019 22:52:53 +1000 Subject: [PATCH] Don't render full category information in part API - Lots of data duplication! - Just send the category ID (and the category name) - --- InvenTree/part/serializers.py | 3 ++- InvenTree/part/templates/part/category.html | 4 ++-- InvenTree/part/templates/part/subcategories.html | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 22a3f8527c..d037e86499 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -43,7 +43,7 @@ class PartSerializer(serializers.ModelSerializer): """ url = serializers.CharField(source='get_absolute_url', read_only=True) - category = CategorySerializer(many=False, read_only=True) + category_name = serializers.CharField(source='category_path', read_only=True) class Meta: model = Part @@ -55,6 +55,7 @@ class PartSerializer(serializers.ModelSerializer): 'URL', # Link to an external URL (optional) 'description', 'category', + 'category_name', 'total_stock', 'available_stock', 'units', diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 111efe7fcf..9c503ce339 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -151,11 +151,11 @@ }, { sortable: true, - field: 'category', + field: 'category_name', title: 'Category', formatter: function(value, row, index, field) { if (row.category) { - return renderLink(row.category.pathstring, row.category.url); + return renderLink(row.category_name, "/part/category/" + row.category + "/"); } else { return ''; diff --git a/InvenTree/part/templates/part/subcategories.html b/InvenTree/part/templates/part/subcategories.html index 4f8704e736..5dcfa426ad 100644 --- a/InvenTree/part/templates/part/subcategories.html +++ b/InvenTree/part/templates/part/subcategories.html @@ -4,7 +4,7 @@