#22268: values_list() on a ManyToManyField returns extra None's when iterated over. -------------------------------------+------------------------------------- Reporter: k_sze | Owner: Type: Bug | anubhav9042 Component: Database layer | Status: assigned (models, ORM) | Version: master Severity: Normal | Resolution: Keywords: orm, values_list, | Triage Stage: Accepted ManyToManyField | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by k_sze): On the one hand, I do understand that a change in behaviour would break backward compatibility. On the other hand, I tend to agree with [comment:10 comment:10] here, in that the behaviour should be modified in the future. To me, the correct behaviour would be to not include the ''extra'' `None`s. In my example, the ones from the null `year_of_birth` are fine and should be included. Another point of consideration that I would raise is whether there is any reason to believe that people are ''relying'' on the current behaviour (I think it would be quite strange for people to be ''relying on ambiguity''). Would it be OK to document it as a ''quirk'' that is subject to change in the future, and not as the ''correct bahaviour''? Regarding [comment:11 comment:11], I think there are possible legitimate uses for this kind of query. For instance, if you want a Cartesian product count of some M2M relation, and then run it through the Python collections.Counter or something. -- Ticket URL: <https://code.djangoproject.com/ticket/22268#comment:13> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/063.f5190402d0e7bdd211e186bb9192c217%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.