Hello Cleiton, I'm a bit surprised only two queries were executed on 1.10 as each time a city string representation is created the associated state will need to be fetched as well.
Were you using any form of select_related()/prefetch_related() to make sure this wasn't an issue? It's possible that the template based widget rendering introduced in 1.11 broke your optimization somehow that would be an actual bug. Simon Le vendredi 12 mai 2017 13:03:23 UTC-4, Cleiton Lima a écrit : > > I do not know if it is a bug or has already been commented > > # models.py > class State(models.Model): > name = models.CharField(_('name'), max_length=60) > > > class Meta: > verbose_name = _('state') > verbose_name_plural = _('states') > > > def __str__(self): > return self.name > > class City(models.Model): > name = models.CharField(_('name'), max_length=60) > state = models.ForeignKey('State', verbose_name=_('state'), > related_name='cities') > > > class Meta: > verbose_name = _('city') > verbose_name_plural = _('cities') > > > def __str__(self): > return '{} - {}'.format(self.name, self.state.name) > > # forms.py > class AnythingForm(forms.ModelForm): > class Meta: > model = Anything > fields = ['city'] > > # template.html > {{form.city}} > > I have 5565 records in model City. > > Django==1.11.1 execute 5565 queries to render select > Django==1.10.7 only 2 > > If replace return '{} - {}'.format(self.name, self.state.name) to > self.name in __str__ of city model, it works. > > Is this really a problem or my mistake? > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/44de2936-3851-49a7-9c36-d66b30ae1fa2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.