diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-31 20:04:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-31 20:04:47 +0100 |
| commit | a9bd01d363376d2e88f96cbf81bc6b77b0ff2bce (patch) | |
| tree | 9937fc37daa462b24822f62f65ed0a29bbda7afc | |
| parent | 3cf907c20c4f4d94f649fbb93a006af5c61b30b8 (diff) | |
Refs #30095 -- Simplified Field._check_choices() a bit.
Using an internal is_value() hook to check whether Field.choices
is iterable is misleading.
| -rw-r--r-- | django/db/models/fields/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index d610dc86f0..ee45bb941e 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -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).", |
