[Django] #23095: clean of ModelMultipleChoiceField tries to return EmptyQuerySet

31 views
Skip to first unread message

Django

unread,
Jul 24, 2014, 1:31:43 PM7/24/14
to django-...@googlegroups.com
#23095: clean of ModelMultipleChoiceField tries to return EmptyQuerySet
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
pedro.celes123@… | Status: new
Type: Bug | Version: 1.6
Component: Forms | Keywords: forms validation
Severity: Normal | ModelMultipleChoiceField queryset.none()
Triage Stage: | Has patch: 0
Unreviewed | UI/UX: 0
Easy pickings: 0 |
-------------------------+-------------------------------------------------
In the clean method of the class ModelMultipleChoiceField if the value of
the field is not and the field is not required the method will return:
{{{#!python
return self.queryset.none()
# In my version (1.6.5, final) this is on line 1180 of file
django/forms/models.py
}}}
However in the release notes it is stated: "The
django.db.models.query.EmptyQuerySet can’t be instantiated any more - it
is only usable as a marker class for checking if none() has been called:
isinstance(qs.none(), EmptyQuerySet)"

So if I have a form which contains a ModelMultipleChoiceField which is not
required and no value is attached to it, in the validation process (more
specifically in the clean of said field) the following error will be
raised:
{{{#!python
TypeError: EmptyQuerySet can't be instantiated
}}}

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

Django

unread,
Jul 24, 2014, 2:26:32 PM7/24/14
to django-...@googlegroups.com
#23095: clean of ModelMultipleChoiceField tries to return EmptyQuerySet
-------------------------------------+-------------------------------------
Reporter: pedro.celes123@… | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.6
Severity: Normal | Resolution:
Keywords: forms validation | Triage Stage:
ModelMultipleChoiceField | Unreviewed
queryset.none() | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I'm having a little trouble understanding how to trigger this error. Could
you write a test case for Django's test suite that demonstrates it?

--
Ticket URL: <https://code.djangoproject.com/ticket/23095#comment:1>

Django

unread,
Jul 24, 2014, 2:37:27 PM7/24/14
to django-...@googlegroups.com
#23095: clean of ModelMultipleChoiceField tries to return EmptyQuerySet
-------------------------------------+-------------------------------------
Reporter: pedro.celes123@… | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.6
Severity: Normal | Resolution:
Keywords: forms validation | Triage Stage:
ModelMultipleChoiceField | Unreviewed
queryset.none() | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by pedro.celes123@…):

Sorry for the inconvenience, due to a monkey patch used in my company I
was fooled to think the problem was with django. After more thorough tests
we discovered the problem was with us.
Really sorry.

--
Ticket URL: <https://code.djangoproject.com/ticket/23095#comment:2>

Django

unread,
Jul 24, 2014, 3:06:27 PM7/24/14
to django-...@googlegroups.com
#23095: clean of ModelMultipleChoiceField tries to return EmptyQuerySet
-------------------------------------+-------------------------------------
Reporter: pedro.celes123@… | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.6
Severity: Normal | Resolution: invalid

Keywords: forms validation | Triage Stage:
ModelMultipleChoiceField | Unreviewed
queryset.none() | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => invalid


Comment:

No problem, thanks for following up.

--
Ticket URL: <https://code.djangoproject.com/ticket/23095#comment:3>

Reply all
Reply to author
Forward
0 new messages