Fix: description count for empty string descriptions

This commit is contained in:
Aroy-Art 2025-02-20 22:21:32 +01:00
parent 319bb8e0f5
commit 98db9ef76d
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -105,9 +105,15 @@ class PostSerializer(serializers.ModelSerializer):
} }
def get_description(self, obj) -> Dict[str, str]: def get_description(self, obj) -> Dict[str, str]:
desc = obj.description.first().content
if desc == "":
count = 0
else:
count = obj.description.count()
return { return {
"count": obj.description.count(), "count": count,
"content": obj.description.first().content, "content": desc,
} }
def get_creator(self, obj) -> Dict[str, str]: def get_creator(self, obj) -> Dict[str, str]: