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: | 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)
Change History (2)
by , 16 years ago
Attachment: | django-onetoonefield.patch added |
---|
comment:1 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I thought I had looked over existing tickets but it seems I missed one.
dupe of #10227