#14615: ORM works for None values too -----------------------------+---------------------------------------------- Reporter: tonnzor | Owner: Status: new | Milestone: 1.3 Component: ORM aggregation | Version: 1.2 Keywords: | Stage: Unreviewed Has_patch: 0 | -----------------------------+---------------------------------------------- Let's say we have 2 models (one refer to another):
{{{ class User(Model): pass class MyObject(Model): user = ForeignKey(User, null=True, blank=True) }}} In this case ORM works wrong in this case: {{{ User().myobject_set.all() # that would return all MyObjects that have user=None }}} So None/null value is supposed to be a valid foreign key between objects with is obviously not. Only if foreign key is not null - then it should be used. I use a simple workaround that may be useful for fixing the issue: {{{ User().myobject_set.exclude(user=None).all() }}} -- Ticket URL: <http://code.djangoproject.com/ticket/14615> 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.