Opened 9 years ago
Last modified 9 years ago
#26366 closed New feature
models.Model.save() method improvement. — at Initial Version
Reported by: | aki33524 | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
class Foo(models.Model): pass class Bar(models.Model): foo = models.ForeignKey(Foo) foo = Foo() bar = Bar(foo=foo) ------------------------- bar.save() <- Fail ------------------------- foo.save() bar.save() <- Fail ------------------------- foo.save() bar.foo = bar.foo bar.save() <- Success!
This is very odd behavior.
And, when implementing foo.save() without writing foo.save(), I wish Django implemented foo.save() implicitly.
Like QuerySet.delete(), ON DELETE CASCADE emulation.
Note:
See TracTickets
for help on using tickets.