Changes between Initial Version and Version 1 of Ticket #31295


Ignore:
Timestamp:
Feb 21, 2020, 4:21:23 AM (5 years ago)
Author:
Aurélien Pardon
Comment:

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.
     1ModelChoiceField use ModelChoiceIterator for its {{{queryset}}}/{{{self.choices}}}, which use {{{.iterator()}}} and doesn't cache the query under some conditions.
    22
    33If 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):
     
    2727
    2828One 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) :
    3029{{{#!python
    3130        if not queryset._prefetch_related_lookups and not self.field.required:
Back to Top