﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27975	Regression on ability to use `queryset=None` on `ModelChoiceField`	James Beith	nobody	"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'
}}}"	Bug	closed	Forms	1.11	Release blocker	fixed			Unreviewed	1	0	0	0	0	0
