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/18df8acf-19f0-458a-96fa-3a28ff9f394c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to