#10811: Assigning unsaved model to a ForeignKey leads to silent failures
-------------------------------------+-------------------------------------
Reporter: Glenn | Owner:
Type: Bug | anubhav9042
Component: Database layer | Status: assigned
(models, ORM) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by altlist):
One could do this and it does what I expect in Django 1.6
{{{
book.author.save()
book.author = book.author # refresh id
book.save()
}}}
So I extended the original patch in #8892 (ticket) and wrote a
save_with_refresh(obj) function.
{{{
book.author.save()
refresh.save_with_refresh(book)
book.save()
}}}
One could modify models.base.save() to accept a "refresh" keyword that
would do the above.
--
Ticket URL: <https://code.djangoproject.com/ticket/10811#comment:26>
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/063.7725521f0f4b6d0a2e8255e826c7db8a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.