wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
222 stars 84 forks source link

wagtail-localize breaks dump/load data #732

Open FlorianLudwig opened 10 months ago

FlorianLudwig commented 10 months ago

Issue Summary

Having wagtail-localize breaks dump/load data

Steps to Reproduce

  1. wagtail start mysite .

  2. python manage.py createsuperuser

  3. Install wagtail-localize python module and add it to INSTALLED_APPS

  4. python manage.py runserver, login and publish subpage below root page

  5. export:

    python manage.py dumpdata --natural-foreign --indent 2 \
    -e contenttypes -e auth.permission \
    -e wagtailcore.groupcollectionpermission \
    -e wagtailcore.grouppagepermission -e wagtailimages.rendition \
    -e sessions > data.json
  6. rm db.sqlite3

  7. python manage.py migrate

  8. python manage.py loaddata data.json

Error: django.db.utils.IntegrityError: Problem installing fixture 'data.json': Could not load wagtailcore.Page(pk=1): constraint failed

Technical details

zerolab commented 10 months ago

Hey @FlorianLudwig thank you for the report.

I just tried this without localize and got the same problem. I had to tweak dumpdata to include -e wagtailsearch.indexentry and got the same error. So this is a core issue :/

tl;dr -

when you run manage.py migrate, the Root page (pk=1) gets created. the dump data also has:

{
  "model": "wagtailcore.page",
  "pk": 1,
  "fields": {
    "path": "0001",
    "depth": 1,
    "numchild": 1,
    "translation_key": "9d32c666-2272-41e1-a685-037061176c76",
    "locale": 1,
    "latest_revision": null,
    "live": true,
    "has_unpublished_changes": false,
    "first_published_at": null,
    "last_published_at": null,
    "live_revision": null,
    "go_live_at": null,
    "expire_at": null,
    "expired": false,
    "locked": false,
    "locked_at": null,
    "locked_by": null,
    "title": "Root",
    "draft_title": "Root",
    "slug": "root",
    "content_type": [
      "wagtailcore",
      "page"
    ],
    "url_path": "/",
    "owner": null,
    "seo_title": "",
    "show_in_menus": false,
    "search_description": "",
    "latest_revision_created_at": null,
    "alias_of": null
  }
},

hence the error