[Bugfix] git status

pull/968/head
ibuler 2018-01-25 12:16:26 +08:00
parent a976475617
commit 070c3d73cc
2 changed files with 5 additions and 3 deletions

View File

@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
class AssetGroup(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=64, unique=True, verbose_name=_('Name'))
created_by = models.CharField(max_length=32, blank=True, verbose_name=_('Created by'))
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
date_created = models.DateTimeField(auto_now_add=True, null=True, verbose_name=_('Date created'))
comment = models.TextField(blank=True, verbose_name=_('Comment'))

View File

@ -13,7 +13,9 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
资产组序列化数据模型
"""
assets_amount = serializers.SerializerMethodField()
assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all())
assets = serializers.PrimaryKeyRelatedField(
many=True, queryset=Asset.objects.all(), required=False
)
class Meta:
model = AssetGroup
@ -22,7 +24,7 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
@staticmethod
def get_assets_amount(obj):
return obj.asset_count
return obj.assets.all().count()
class AssetUpdateSystemUserSerializer(serializers.ModelSerializer):