Do queries made instantiating a form not show up in db.connection.queries?

14 views
Skip to first unread message

Jonathan Berger

unread,
Nov 1, 2018, 8:14:53 PM11/1/18
to django...@googlegroups.com
Hi Django Users,

I'm a moderate-level user of Django and trying to determine if I've found a bug.

Per the db and model FAQ: expected behavior is that 'connection.queries' should contain a list of all SQL queries made by an app.

I'm finding actual behavior for a Form subclass that has a ModelMultipleChoiceField with a default queryset, does not add that query to 'connection.queries'. This violates expected behavior.

Am I misunderstanding something or is this a bug?

Thanks,
Jonathan

Karen Tracey

unread,
Nov 1, 2018, 9:12:33 PM11/1/18
to django...@googlegroups.com
On Thu, Nov 1, 2018 at 8:14 PM Jonathan Berger <jonatha...@gmail.com> wrote:

Per the db and model FAQ: expected behavior is that 'connection.queries' should contain a list of all SQL queries made by an app.

I'm finding actual behavior for a Form subclass that has a ModelMultipleChoiceField with a default queryset, does not add that query to 'connection.queries'. This violates expected behavior.


https://docs.djangoproject.com/en/2.1/ref/forms/fields/#django.forms.ModelChoiceField.queryset notes the queryset is "evaluated when the form is rendered." ...are you rendering the form or just instantiating it (per the subject)?

Karen
 

Jonathan Berger

unread,
Nov 2, 2018, 1:20:15 AM11/2/18
to django...@googlegroups.com
Thank you!

I was looking at the value of 'connection.queries' before rendering the form.

--
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...@googlegroups.com.
To post to this group, send email to django...@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/CACS9racCtAAgPLwv7-SBw-40Sddge_r9hpBS5eDBqE_1GGJbqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages