Skip to content
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] Click "New Draft" cause error UNIQUE constraint failed: cms_pagecontent.language, cms_pagecontent.page_id #7732

Open
TLuesebrinck opened this issue Jan 3, 2024 · 12 comments
Labels

Comments

@TLuesebrinck
Copy link

Click "New Draft" cause error UNIQUE constraint failed: cms_pagecontent.language, cms_pagecontent.page_id

Django Version: 4.2.9
IntegrityError
UNIQUE constraint failed: cms_pagecontent.language, cms_pagecontent.page_id
.env\Lib\site-packages\django\db\backends\sqlite3\base.py, line 328, in execute djangocms_versioning.admin.edit_redirect_view
.env\Scripts\python.exe 3.11.7
@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 3, 2024

@TLuesebrinck I am afraid, so far, I cannot reproduce the error. Do you remember how you got your db into this state? Have you fully run djangocms-versioning's migrations? It should have removed the uniqueness constraints for PageContent.

I have had issues when adding versioning to the project, removing it, making changes, and adding versioning back again. I am not sure if these are the same. Did you add or remove djangocms-versionging temporarily?

@TLuesebrinck
Copy link
Author

I followed the manual "Installing django CMS by hand" and the step "djangocms myproject" should do all the steps to run the project. But after some problems occurred, I checked the migrations, and it seems this step was not completed. I had to call makemigrations then migrate. I am not 100% sure, but it could be possible that I create a page and check the migration later.

@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 4, 2024

djangocms should actually settle everything for you in the sqlite database it uses. If the djangocms command had failed, it would have done so with an error message. Upon success it prints a success message - something like

Check installation
python -m manage cms check

***************************************
django CMS 4.1.0 installed successfully
***************************************

Congratulations! You have successfully installed django CMS,
the lean enterprise content management powered by Django!

Now, to start the development server first go to your newly
created project and then call the runserver management command:
$ cd blabla/bla
$ python -m manage runserver

Learn more at https://docs.django-cms.org/
Join the django CMS Slack channel http://www.django-cms.org/slack

Enjoy!

Now, that you ran the migrations, can you create a new draft?

@TLuesebrinck
Copy link
Author

TLuesebrinck commented Jan 4, 2024 via email

@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 4, 2024

One more idea comes to my mind, but I am medium-optimistic it will work. Can you try:

  1. cd into the folder which contains your virtual environment
  2. $ pip install git+https://github.com/django-cms/djangocms-versioning
  3. cd into the project folder
  4. $ python -m manage create_versions

Please let me know if the command returns any fixes.

If that does not help, I'd be happy to schedule a google meet and try to debug. Alternatively, you could share your database db.sqlite3 privately, so we can get a grip of what has happened.

@TLuesebrinck
Copy link
Author

TLuesebrinck commented Jan 4, 2024 via email

@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 4, 2024

Try uninstalling djangocms-versioning first, then.

@TLuesebrinck
Copy link
Author

TLuesebrinck commented Jan 4, 2024 via email

@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 4, 2024

The output is correct.

The last resort will be to delete the db.sqlite3 file (obviously losing everything entered into the DB) and run migrations and createsuperuser again to see if the bug appears once more. If so, please try reporting the exact steps you took.

@TLuesebrinck
Copy link
Author

TLuesebrinck commented Jan 4, 2024 via email

@fsbraun
Copy link
Sponsor Member

fsbraun commented Jan 4, 2024

Thank you, @TLuesebrinck ! Those are valuable inputs. Thank you very much! A few quick comments:

  • If no root page exists, the "create" wizard is opened automatically to allow a new user to create a page. An existing, but unpublished page leads to the 404 error. A redirect in the latter case would not allow for an unpublished root page.
  • The next release of djangocms-frontend will by default retrieve bootstrap 5.3.x from a CDN. This is for convenience only, and developers are strongly encouraged to create their own base template, providing their preferred style sheets.
  • Can you open a separate issue for the message colours and duration?
  • If've been thinking to remove the labels from the row and col fields in djangocms-frontend - they are redundant and only meant to help navigate (am I filling the correct field?). A decision has not been made. When looking at it, I realize those fields are harder to read in dark mode. In light mode, I, personally, do not find them distracting.
  • You get auto entries for the column width by typing "0" (or using the arrows).
  • To navigate the plugin tree, holding the shift key can be helpful. When hovering plugins on the page, their entry in the structure board will highlight and vice versa. For me, this is often the easiest way to find plugins in the tree.
  • Overlapping read-only fields in the admin are due to changes in Django 4.2+'s admin CSS. This is fixed in djangocms-admin-style 3.2.7 due any day now.

@TLuesebrinck
Copy link
Author

TLuesebrinck commented Jan 5, 2024 via email

@fsbraun fsbraun marked this as a duplicate of #7838 Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants