diff options
| author | James Beith <james@beith.co.uk> | 2017-03-22 16:38:16 +1100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-03-22 08:57:02 -0400 |
| commit | 6963564ecc1b84cb2510616123a27d368bc76a1f (patch) | |
| tree | a5845dc130f5fce785b0533faf521b94a53d405c /django/forms | |
| parent | da72d0730eb0ff335404c13925afc962ac565c79 (diff) | |
[1.11.x] Fixed #27975 -- Fixed crash if ModelChoiceField's queryset=None.
Regression in 9153d8fbd6385db9f48793662de789fc3d686841.
Backport of 216bb2e8fbc3cb37615bbd70edaa73287acdca81 from master
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/models.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index de0ab6c28d..af324c2b27 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -1165,7 +1165,8 @@ class ModelChoiceField(ChoiceField): def __deepcopy__(self, memo): result = super(ChoiceField, self).__deepcopy__(memo) # Need to force a new ModelChoiceIterator to be created, bug #11183 - result.queryset = self.queryset.all() + if self.queryset is not None: + result.queryset = self.queryset.all() return result def _get_queryset(self): |
