diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-07-31 20:02:23 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-31 11:02:23 -0400 |
| commit | aadd3aeb2ba3153e35bd805c80c901f289a6f333 (patch) | |
| tree | 20d37a25e7ae620c12886dfe5aed981590dfd2dc /django/forms | |
| parent | 0f905e4b4479894f67b12ad976402a9660f0cae4 (diff) | |
Avoided creating temporary lists for obtaining the first item.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/forms/utils.py b/django/forms/utils.py index 587cea85a3..9bdaffa44b 100644 --- a/django/forms/utils.py +++ b/django/forms/utils.py @@ -95,7 +95,7 @@ class ErrorList(UserList, list): def get_json_data(self, escape_html=False): errors = [] for error in self.as_data(): - message = list(error)[0] + message = next(iter(error)) errors.append({ 'message': escape(message) if escape_html else message, 'code': error.code or '', @@ -133,7 +133,7 @@ class ErrorList(UserList, list): def __getitem__(self, i): error = self.data[i] if isinstance(error, ValidationError): - return list(error)[0] + return next(iter(error)) return error def __reduce_ex__(self, *args, **kwargs): |
