Opened 16 years ago

Closed 15 years ago

#11053 closed (duplicate)

access to OneToOneField when null=True should return None instead of raising DoesNotExist

Reported by: Harm Geerts <hgeerts@…> Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Place(models.Model):
    name = models.CharField(max_length=50)

class UndergroundBar(models.Model):
    place = models.OneToOneField(Place, null=True)

Django behaves differently with access to the OneToOneField depending on which side of the relation is used.
Currently UndergroundBar.place will return None while Place.undergroundbar raises DoesNotExist.

Attachments (1)

django-onetoonefield.patch (1.5 KB ) - added by Harm Geerts <hgeerts@…> 16 years ago.

Download all attachments as: .zip

Change History (2)

by Harm Geerts <hgeerts@…>, 16 years ago

Attachment: django-onetoonefield.patch added

comment:1 by Harm Geerts <hgeerts@…>, 15 years ago

Resolution: duplicate
Status: newclosed

I thought I had looked over existing tickets but it seems I missed one.
dupe of #10227

Note: See TracTickets for help on using tickets.
Back to Top