#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.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2dc87f9192bb6242c14b07cfcd9933e8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to