#31295: required ModelChoiceField makes duplicate (cursor) queries to the 
database
-------------------------------------+-------------------------------------
     Reporter:  Aurélien Pardon      |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Forms                |                  Version:  2.2
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:  Model                |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Aurélien Pardon):

 The fact that the following code makes '''two''' requests to the database
 :
 {{{#!python
 class MyModel(models.Model):
     my_field = models.CharField(max_length=1)

 class MyForm(forms.Form):
     my_form_field = forms.ModelChoiceField(MyModel.objects.all(),
 empty_label=None)

 my_form.as_ul()
 }}}
 is absolutely not working as intended. Show this to any other core dev and
 ask them, please.


 This whole "invalid HTML code" is not an important issue. It happens yes,
 but under very rare circumstances (a blank primary key and an {{{INSERT}}}
 between the two '''identical''' requests to the database), and it also
 won't bother any browser. I can work hard and show you the invalid HTML
 code (using database trigger to emulate race conditions?) but honestly
 it's not the problem.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31295#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.717313c12a54f3c538e3a3906178d6f4%40djangoproject.com.

Reply via email to