New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] create_page_content API adding two cms_pagecontent records instead of one #7796
Comments
Two |
Yes extra records in both, a work around to get to the settings after page creation is to delete one instance of the PageURL instance - as this is what is causing the error (and records are 100% identical). dupe_pageurl_record = PageUrl.objects.filter(page_id=main_page.pk,language=language).first() When deleted like this, can access the settings page as expected. There are differences on the two different PageContnet records though. |
@jamesfogg OK, after looking at your code, I think I know the reason:
I expect, if you follow this path, you will only have one page url and only one page content object. My take-away is that |
For a page created manually from Admin, can click into page settings.
For any pages that have been created using the API, getting this error when trying to then click into settings.
MultipleObjectsReturned at /en/admin/cms/pagecontent/158/change/
get() returned more than one PageUrl -- it returned 2!
Looking at the pagecontent table in the dB.
When a page is created manually - one pageholder record is created with template type = INHERIT
When a page, and then pagecontent is created using the API. There are two records -
One which has the template as specified in the pagecontent create call.
The second record has the template specified as template = INHERIT
Essentially looks like the API is firing the creation of the requested record and then an additional default placeholder record is also being created which causes the above settings issue. Also looks like 2x dupe cms_pageurl records are being create as a consequence
Steps to reproduce
Manually create a page from admin screen, click on settings - all ok.
Vs.
Create a page/page content using the API as follows:
parent_page = self.get_parent_page(parent_path)
node_parent = parent_page.node if parent_page else None
draft_page = Page.objects.filter(pagecontent_set__title=page_title, node__parent=node_parent).first()
Expected behaviour
One cms_pagecontent record to be created when page created via API
Actual behaviour
Two cms_pagecontent records created - one with template specified in the API call, the other with template type = INHERIT
Screenshots
N/A
311 / 4.1
Do you want to help fix this issue?
The text was updated successfully, but these errors were encountered: