On Thu, May 13, 2010 at 7:31 PM, Daniel Roseman <dan...@roseman.org.uk> wrote: > > > On May 13, 5:35 pm, Peter Herndon <tphern...@gmail.com> wrote: >> On May 13, 2010, at 10:29 AM, TallFurryMan wrote: >> >> > Hello Django users, >> >> > Is there a particular reason why using a related OneToOneField raises >> > DoesNotExist instead of returning None? >> >> Any query you make that is supposed to return one or more instances, that >> instead cannot find any results, returns a DoesNotExist. > > Not true - a .filter() query returns an empty QuerySet if no results > are found. However a .get() query does raise DoesNotExist if it > doesn't find anything - which is the exact equivalent of a > OneToOneField lookup.
To get super pedantic, he said 'any query that is supposed to return one or more instances' would raise a DoesNotExist. You countered with a .filter() query, which returns 0 or more instances. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.