Changes between Initial Version and Version 1 of Ticket #31295
- Timestamp:
- Feb 21, 2020, 4:21:23 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31295 – Description
initial v1 1 ModelChoiceField use ModelChoiceIterator for its {{{ queryset }}}/{{{ self.choices}}}, which use {{{.iterator()}}} and doesn't cache the query under some conditions.1 ModelChoiceField use ModelChoiceIterator for its {{{queryset}}}/{{{self.choices}}}, which use {{{.iterator()}}} and doesn't cache the query under some conditions. 2 2 3 3 If the field is required, the method use_required_attribute (https://github.com/django/django/blob/master/django/forms/widgets.py#L689) fetch the first choice, making a duplicate query to the database (worse than a useless query, the data may have changed): … … 27 27 28 28 One solution would be to add another test to the previous piece of code : 29 (https://github.com/django/django/blob/da79ee472d803963dc3ea81ee67767dc06068aac/django/forms/models.py#L1152) :30 29 {{{#!python 31 30 if not queryset._prefetch_related_lookups and not self.field.required: