#24418 closed Bug (fixed)
refresh_from_db is breaking on null foreign keys
Reported by: | Johannes Lerch | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8alpha1 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If i try to call refresh_from_db on a model instance that has a foreignkey set to null, i get an error:
(stacktrace was removed after ticket was resolved)
here rel_instance is assigned:
https://github.com/django/django/blob/stable/1.8.x/django/db/models/base.py#L630
if it is None (foreignkey not set, as it is nullable in this model) the getattr function will complain that it can not get 'id' from 'NoneType'
Attachments (1)
Change History (7)
comment:1 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
by , 10 years ago
Attachment: | 24418-test.diff added |
---|
comment:2 by , 10 years ago
Has patch: | set |
---|
comment:3 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 10 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
Reproduced with the attached test.