{"action":"opened","issue":{"url":"https://api.github.com/repos/torchbox/wagtail/issues/1853","labels_url":"https://api.github.com/repos/torchbox/wagtail/issues/1853/labels{/name}","comments_url":"https://api.github.com/repos/torchbox/wagtail/issues/1853/comments","events_url":"https://api.github.com/repos/torchbox/wagtail/issues/1853/events","html_url":"https://github.com/torchbox/wagtail/issues/1853","id":112696559,"number":1853,"title":"InlinePanel alway creates new objects","user":{"login":"nomeata","id":148037,"avatar_url":"https://avatars.githubusercontent.com/u/148037?v=3","gravatar_id":"","url":"https://api.github.com/users/nomeata","html_url":"https://github.com/nomeata","followers_url":"https://api.github.com/users/nomeata/followers","following_url":"https://api.github.com/users/nomeata/following{/other_user}","gists_url":"https://api.github.com/users/nomeata/gists{/gist_id}","starred_url":"https://api.github.com/users/nomeata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomeata/subscriptions","organizations_url":"https://api.github.com/users/nomeata/orgs","repos_url":"https://api.github.com/users/nomeata/repos","events_url":"https://api.github.com/users/nomeata/events{/privacy}","received_events_url":"https://api.github.com/users/nomeata/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-21T23:04:05Z","updated_at":"2015-10-21T23:04:05Z","closed_at":null,"body":"Hi,\r\n\r\nI have a simple setup like this:\r\n```\r\nclass APage(Page):\r\n    content_panels = Page.content_panels + [\r\n        InlinePanel('ordnungen', label=\"Ordnungen\"),\r\n    ]\r\n\r\n\r\nclass Ordnung(Orderable):\r\n    page = ParentalKey(APage, related_name='ordnungen')\r\n    ordnung = models.CharField(max_length=250)\r\n    panels = [\r\n            FieldPanel('ordnung')\r\n    ]\r\n```\r\n\r\nAs expected, I can create a  `APage`, and edit the set of `Ordnung` there. The problem is that whenever I publish the page, wagtail (or rather modelcluster) deletes all existing objects and creates new ones from the content in the forms. This can be observed by looking at the ids of the objects, and obviously breaks anything that references these objects.\r\n\r\nI can work around the issue by issuing `delete * from wagtailcore_pagerevision`. Also, a bit of naive `print()` and `traceback` debugging in modelcluster shows me that wagtail always adds these objects from the JSON representation, and _never_ from the DB. The data in `wagtailcore_pagerevision` always has `pk: null`; I would expect that to be a valid id after the first publish. Indeed, after the work-around (`delete * from wagtailcore_pagerevision`), the next time I edit the page, the data _is_ read from db, the objects are now stored _with_ `pk` in the JSON, and further edits to _these_ object preserve the data base objects. Newly added objects, though, still show the old recreate-on-every-publish behaviour.\r\n\r\nMy bet is that wagtail, when editing a page, re-uses the last entry in `wagtailcore_pagerevision` to populate the forms and managers and what not, and my conclusion is that it should do that only for pages that are in “draft” mode, and not for those that have been published previous. This way, in the latter case, the current `pk` values find their way into the JSON."}}