﻿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
27501	ModelChoiceField.queryset documentation isn't clear that this is lazily evaluated	Nick Smith	nobody	"The [https://github.com/django/django/blob/master/django/forms/models.py#L1197 comments] in `ModelChoiceField._get_choices` suggest that the `queryset` attribute is evaluated afresh every time the form is initialised, and testing confirms this:

1. load form
1. edit eligible related objects in the db
1. refresh form (without restarting the server)
1. observe field choices have changed

[ticket: 22841] also supports this theory, (although the rather old [ticket: 18272] suggests otherwise).

The syntax for a field of this type is:

{{{#!python
    foo = forms.ModelChoiceField(
        queryset=Bar.objects.filter(baz=True)
    )
}}}

Given that this looks very like a runtime-evaluated queryset, I suggest a docs amendment that clarifies the behaviour. (I am not confident in making that docs amendment myself, at least until I have properly understood the intended behaviour.)"	Uncategorized	new	Documentation	1.10	Normal				Unreviewed	0	0	0	0	1	0
