#9981: getting objects where column is null throws exception, when you define
ordering by that column
--------------------------------------------+-------------------------------
Reporter: [email protected] | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: SVN
Keywords: foreign keys, null, get | Stage: Unreviewed
Has_patch: 0 |
--------------------------------------------+-------------------------------
i have the following class defined:
{{{
#!python
class Foo(models.Model):
bar = models.ForeignKey(Bar, null=True, blank=True)
name = models.CharField(max_length=100, null=True, blank=True)
class Meta:
ordering = ['bar', 'name']
}}}
now trying to get an object throws this exception, unless you don't delete
'bar' from ordering:
{{{
>>> f = Foo(name="asdf")
>>> f.save()
>>> f.id
38500L
>>> f2 = Foo.objects.get(id=38500)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/tools/python/lib/python2.5/site-
packages/django/db/models/manager.py", line 93, in get
return self.get_query_set().get(*args, **kwargs)
File "/tools/python/lib/python2.5/site-
packages/django/db/models/query.py", line 309, in get
% self.model._meta.object_name)
DoesNotExist: Foo matching query does not exist.
}}}
is there already a bugfix? of course there is a workaround here with
order_by but you can search a very long time until you find it
thank you,
antje
--
Ticket URL: <http://code.djangoproject.com/ticket/9981>
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---