mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-12-04 00:34:00 +03:00
Use enumerate for index and item in loop
This commit is contained in:
parent
54d649b8ed
commit
681582bfcf
|
|
@ -689,16 +689,14 @@ class ListSerializer(BaseSerializer):
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
errors = {}
|
errors = {}
|
||||||
index = 0
|
|
||||||
|
|
||||||
for item in data:
|
for index, item in enumerate(data):
|
||||||
try:
|
try:
|
||||||
validated = self.run_child_validation(item)
|
validated = self.run_child_validation(item)
|
||||||
except ValidationError as exc:
|
except ValidationError as exc:
|
||||||
errors[index] = exc.detail
|
errors[index] = exc.detail
|
||||||
else:
|
else:
|
||||||
ret.append(validated)
|
ret.append(validated)
|
||||||
index += 1
|
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user