Fix: description count for empty string descriptions
This commit is contained in:
parent
319bb8e0f5
commit
98db9ef76d
1 changed files with 8 additions and 2 deletions
|
@ -105,9 +105,15 @@ class PostSerializer(serializers.ModelSerializer):
|
|||
}
|
||||
|
||||
def get_description(self, obj) -> Dict[str, str]:
|
||||
desc = obj.description.first().content
|
||||
if desc == "":
|
||||
count = 0
|
||||
else:
|
||||
count = obj.description.count()
|
||||
|
||||
return {
|
||||
"count": obj.description.count(),
|
||||
"content": obj.description.first().content,
|
||||
"count": count,
|
||||
"content": desc,
|
||||
}
|
||||
|
||||
def get_creator(self, obj) -> Dict[str, str]:
|
||||
|
|
Loading…
Add table
Reference in a new issue