1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Refs #30095 -- Simplified Field._check_choices() a bit.

Using an internal is_value() hook to check whether Field.choices
is iterable is misleading.
This commit is contained in:
Mariusz Felisiak 2019-10-31 20:04:47 +01:00 committed by GitHub
parent 3cf907c20c
commit a9bd01d363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,10 +241,10 @@ class Field(RegisterLookupMixin):
if not self.choices:
return []
def is_value(value, accept_promise=True):
return isinstance(value, (str, Promise) if accept_promise else str) or not is_iterable(value)
def is_value(value):
return isinstance(value, (str, Promise)) or not is_iterable(value)
if is_value(self.choices, accept_promise=False):
if not is_iterable(self.choices) or isinstance(self.choices, str):
return [
checks.Error(
"'choices' must be an iterable (e.g., a list or tuple).",