#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 anubhav9042):
Well I went through the entire problem today thoroughly.
The problem is that when in the `inline` test(which causes errors), we are
trying to create an object on the fly and then since it has no `id` so it
cannot be used. Following Aymeric's comments above line by line its true
that form gets fields: `['et', 'place']` out of which `et` which is FK
creates problem in form validation step in `_post_clean` when
`construct_instance` is called.
We need a saved object of `ExtraTerrestrial` class for its `id` to be
saved in `Sighting`.
As far as I think, there are other tests in same test file with models
using the FK, why not try to implement the error causing test case in a
similar way/ or create an object before and send it(dunno if the second
part is possible)
Or
Is it possible to write a check in `_post_clean` and prevent calling of
`construct_instance`?
Need some guidance here.
A similarity between failing tests: Both are dealing with inherited
models. Although I don't think that might be a problem here but still I
thought it better to post.
--
Ticket URL: <https://code.djangoproject.com/ticket/10811#comment:24>
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.f8c2be7c2f4e8fb2c78543d20dc3cbb1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.