From 5f2ca58d6228fc16a68be00c5ddb696eb9820b37 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 31 Jan 2018 18:59:43 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9label=20api=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/label.py | 4 ---- apps/assets/serializers.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/assets/models/label.py b/apps/assets/models/label.py index 10038d5d4..990a71ca8 100644 --- a/apps/assets/models/label.py +++ b/apps/assets/models/label.py @@ -29,10 +29,6 @@ class Label(models.Model): for name in names: yield name, cls.objects.filter(name=name) - @property - def asset_count(self): - return self.assets.count() - def __str__(self): return "{}:{}".format(self.name, self.value) diff --git a/apps/assets/serializers.py b/apps/assets/serializers.py index 08a27b358..3b871e5ba 100644 --- a/apps/assets/serializers.py +++ b/apps/assets/serializers.py @@ -297,7 +297,7 @@ class LabelSerializer(serializers.ModelSerializer): @staticmethod def get_asset_count(obj): - return obj.asset_count + return obj.assets.count() def get_field_names(self, declared_fields, info): fields = super().get_field_names(declared_fields, info)