#27975: Regression on ability to use `queryset=None` on `ModelChoiceField`
-------------------------------------------+------------------------
               Reporter:  James Beith      |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Forms            |        Version:  1.11
               Severity:  Release blocker  |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  1
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 The change in ticket #27563 has unfortunately caused a regression in the
 ability to use `queryset=None` on `ModelChoiceField` and later set the
 QuerySet in the form's `__init__` method.

 This functionality is described in
 [https://docs.djangoproject.com/en/1.11/ref/forms/fields/#fields-which-
 handle-relationships Django's documentation].

 Please see included patch in the following pull request:
 [https://github.com/django/django/pull/8232 #8232]

 {{{
 Traceback (most recent call last):
   File
 "/Users/James/Documents/Work/GitHub/django/django/tests/model_forms/tests.py",
 line 1657, in test_modelchoicefield_queryset_none
     form1 = ModelChoiceForm()
   File
 "/Users/James/Documents/Work/GitHub/django/django/tests/model_forms/tests.py",
 line 1654, in __init__
     super().__init__(*args, **kwargs)
   File
 "/Users/James/Documents/Work/GitHub/django/django/django/forms/forms.py",
 line 96, in __init__
     self.fields = copy.deepcopy(self.base_fields)
   File "/Users/James/.virtualenvs/django/lib/python3.6/copy.py", line 180,
 in deepcopy
     y = _reconstruct(x, memo, *rv)
   File "/Users/James/.virtualenvs/django/lib/python3.6/copy.py", line 306,
 in _reconstruct
     value = deepcopy(value, memo)
   File "/Users/James/.virtualenvs/django/lib/python3.6/copy.py", line 161,
 in deepcopy
     y = copier(memo)
   File
 "/Users/James/Documents/Work/GitHub/django/django/django/forms/models.py",
 line 1169, in __deepcopy__
     result.queryset = self.queryset.all()
 AttributeError: 'NoneType' object has no attribute 'all'
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27975>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.cc45768beba82e522689e0a0daf4976e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to