#25715: refresh_from_db fails to update null'ed ForeignKeys
-------------------------------+--------------------
Reporter: joshkel | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have User and Org models, with User having a ForeignKey to Org:
{{{#!python
org = models.ForeignKey('Org', null=True, blank=True,
on_delete=models.SET_NULL)
}}}
If I delete an Org instance then refresh the User instance, then
user.org_id is cleared as expected, but user.org still references the
deleted instance:
{{{#!python
org = create_org()
user = create_user(org)
org.delete()
user.refresh_from_db()
self.assertIsNone(user.org_id) # Works!
self.assertIsNone(user.org) # Fails!
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25715>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.c97a4793555c1875992c58f23099f750%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.