﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14615	Related objects manager returns related objects with null FKs for unsaved instances	Artem Skoretskiy		"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()
}}}"	Bug	closed	Database layer (models, ORM)	1.2	Normal	fixed		Artem Skoretskiy <tonn81@…> victor.van.den.elzen@…	Accepted	1	0	0	1	0	0
