#12870: ORM bug with using exclude in conjunction with Q objects ---------------------------------------------------+------------------------ Reporter: subsume | Owner: nobody Status: new | Milestone: 1.2 Component: Database layer (models, ORM) | Version: 1.1 Resolution: | Keywords: exclude Q Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Comment (by mucisland):
Sorry for blending in, but I got the same problem. Using kwargs, exclude() works just fine: {{{ >>> units.exclude(cpe_model__chipset__name__icontains="ac5") }}} ...returns the units which do not contain "ac5" in the chipset name of their related cpe_model. When using Q, exclude() has a problem: {{{ >>> units.exclude(Q(cpe_model__chipset__name__icontains="ac5") }}} ...'''also excludes units which have an empty chipset field in their related cpe_model.''' Sorry for not providing a reproducable session log, but my app is quite complex and I didn't manage to extract just the important models and relations. But as user subsume already showed, the SQL query of exclude(Q()) is missing the ''AND NOT (`deck_deck`.`category` IS NULL)'' in the WHERE clause. -- Ticket URL: <http://code.djangoproject.com/ticket/12870#comment:6> Django <http://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 post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.