Fixes: 1) Correct invalid return type in get_children; 2) Update default return value from {} to [];
Extra: 1) Adjust inline comments for better clarity; 2) General cleanup in `simple.py`.
This commit is contained in:
parent
e312cb8a71
commit
e9219c8918
1 changed files with 3 additions and 3 deletions
|
|
@ -52,7 +52,7 @@ class CategorySimpleSerializer(ModelSerializer):
|
|||
"children",
|
||||
]
|
||||
|
||||
def get_children(self, obj: Category) -> dict[str, Any]:
|
||||
def get_children(self, obj: Category) -> list[dict[str, Any]]:
|
||||
request = self.context.get("request")
|
||||
if request is not None and request.user.has_perm("view_category"):
|
||||
children = obj.children.all()
|
||||
|
|
@ -63,8 +63,8 @@ class CategorySimpleSerializer(ModelSerializer):
|
|||
serializer = CategorySimpleSerializer(
|
||||
children, many=True, context=self.context
|
||||
)
|
||||
return dict(serializer.data) # ty: ignore[invalid-return-type]
|
||||
return {}
|
||||
return list(serializer.data)
|
||||
return []
|
||||
|
||||
|
||||
class BrandSimpleSerializer(ModelSerializer):
|
||||
|
|
|
|||
Loading…
Reference in a new issue