Code Monkey home page Code Monkey logo

Comments (3)

fsbraun avatar fsbraun commented on June 10, 2024

Two PageContent objects AND two PageURL objects?

from django-cms.

jamesfogg avatar jamesfogg commented on June 10, 2024

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()
dupe_pageurl_record.delete()

When deleted like this, can access the settings page as expected. There are differences on the two different PageContnet records though.

from django-cms.

fsbraun avatar fsbraun commented on June 10, 2024

@jamesfogg OK, after looking at your code, I think I know the reason:

  • create_page already creates a PageContent object
  • You need to create or get the page. Important: do not forget to provide a created_by argument.
  • Instead of create_pagecontent you'll have to get the existing content by using page.pagecontent_set(manager="admin_manager").latest_content() Only if this should be empty, create a page content object manually.
  • From there you get the placeholder.

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 create_pagecontent needs to check if there already is a content object before creating a new one.

from django-cms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.