﻿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
6738	Cannot get objects when an attribute is None	John <john@…>	nobody	"I have a model defined like this:

{{{
class Reported(models.Model):
    user = models.ForeignKey(User, null=True)
    link = models.ForeignKey(Link)
    date = models.DateTimeField(auto_now_add=True)
}}}

but when I execute this on the shell, it gives an erroneous result.
{{{
>>> Reported.objects.create(user=None, link=Link.objects.get(id=2))
<Reported: Reported object>
>>> Reported.objects.get(user=None, link=Link.objects.get(id=2))
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""C:\Python25\lib\site-packages\django\db\models\manager.py"", line 69, in
get
    return self.get_query_set().get(*args, **kwargs)
  File ""C:\Python25\lib\site-packages\django\db\models\query.py"", line 263, in g
et
    raise self.model.DoesNotExist, ""%s matching query does not exist."" % self.mo
del._meta.object_name
DoesNotExist: Reported matching query does not exist.
}}}


As you can see, I first create an object, and then search for it, but the just-created item cannot be found! This only happens when one of the search fields is None, the following works:
{{{
Reported.objects.get(link=Link.objects.get(id=2))
}}}"		closed	Database layer (models, ORM)	dev		invalid	db, error, data corruption		Unreviewed	0	0	0	0	0	0
