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

Importing content with media fails to due database constraint violations. #18

Open
skini-galaxia opened this issue Mar 18, 2021 · 3 comments

Comments

@skini-galaxia
Copy link

Error Logs

django.db.utils.IntegrityError: insert or update on table "bootstrap4_picture_bootstrap4picture" violates foreign key constraint "bootstrap4_picture_b_picture_id_f26d968d_fk_filer_ima"
web_1               | DETAIL:  Key (picture_id)=(6) is not present in table "filer_image".
New
12:56
Internal Server Error: /admin/cms/page/plugin/plugin_importer/import-plugins/
web_1               | Traceback (most recent call last):
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               | psycopg2.errors.ForeignKeyViolation: insert or update on table "bootstrap4_picture_bootstrap4picture" violates foreign key constraint "bootstrap4_picture_b_picture_id_f26d968d_fk_filer_ima"
web_1               | DETAIL:  Key (picture_id)=(6) is not present in table "filer_image".
web_1               |
web_1               |
web_1               | The above exception was the direct cause of the following exception:
web_1               |
web_1               | Traceback (most recent call last):
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
web_1               |     response = get_response(request)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
web_1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1               |   File "/usr/local/lib/python3.8/site-packages/djangocms_transfer/cms_plugins.py", line 147, in import_plugins_view
web_1               |     import_form.run_import()
web_1               |   File "/usr/local/lib/python3.8/site-packages/djangocms_transfer/forms.py", line 159, in run_import
web_1               |     import_plugins(
web_1               |   File "/usr/local/lib/python3.8/contextlib.py", line 75, in inner
web_1               |     return func(*args, **kwds)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/transaction.py", line 232, in __exit__
web_1               |     connection.commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
web_1               |     return func(*args, **kwargs)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 266, in commit
web_1               |     self._commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
web_1               |     raise dj_exc_value.with_traceback(traceback) from exc_value
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               | django.db.utils.IntegrityError: insert or update on table "bootstrap4_picture_bootstrap4picture" violates foreign key constraint "bootstrap4_picture_b_picture_id_f26d968d_fk_filer_ima"
web_1               | DETAIL:  Key (picture_id)=(6) is not present in table "filer_image".
web_1               |
web_1               | [2021-03-18 03:13:08,290] {log.py:224} ERROR - Internal Server Error: /admin/cms/page/plugin/plugin_importer/import-plugins/
web_1               | Traceback (most recent call last):
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               | psycopg2.errors.ForeignKeyViolation: insert or update on table "bootstrap4_picture_bootstrap4picture" violates foreign key constraint "bootstrap4_picture_b_picture_id_f26d968d_fk_filer_ima"
web_1               | DETAIL:  Key (picture_id)=(6) is not present in table "filer_image".
web_1               |
web_1               |
web_1               | The above exception was the direct cause of the following exception:
web_1               |
web_1               | Traceback (most recent call last):
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
web_1               |     response = get_response(request)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
web_1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1               |   File "/usr/local/lib/python3.8/site-packages/djangocms_transfer/cms_plugins.py", line 147, in import_plugins_view
web_1               |     import_form.run_import()
web_1               |   File "/usr/local/lib/python3.8/site-packages/djangocms_transfer/forms.py", line 159, in run_import
web_1               |     import_plugins(
web_1               |   File "/usr/local/lib/python3.8/contextlib.py", line 75, in inner
web_1               |     return func(*args, **kwds)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/transaction.py", line 232, in __exit__
web_1               |     connection.commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
web_1               |     return func(*args, **kwargs)
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 266, in commit
web_1               |     self._commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
web_1               |     raise dj_exc_value.with_traceback(traceback) from exc_value
web_1               |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 242, in _commit
web_1               |     return self.connection.commit()
web_1               | django.db.utils.IntegrityError: insert or update on table "bootstrap4_picture_bootstrap4picture" violates foreign key constraint "bootstrap4_picture_b_picture_id_f26d968d_fk_filer_ima"
web_1               | DETAIL:  Key (picture_id)=(6) is not present in table "filer_image".
@avryhof
Copy link

avryhof commented Jun 22, 2021

The problem is the last sentence in the first paragraph of the readme.

It does not support foreign key relations and won't import/export related data.

I wish there was an option to export the content while simply exporting the foreignkeys as null. That way we could export all of the plugins with their settings, then re-add Django Filer objects. I have a rather large site where I've had to set aside about a week just to rebuild all of the content from the Staging server onto the production server. Being able to export the plugins, re-import them then just upload the images/files anew would save a lot of time.

wesleyboar added a commit to wesleyboar/djangocms-transfer that referenced this issue Nov 4, 2021
Issue django-cms#18 shows that the current wording is not intuitive to all users. An example could help.
marksweb pushed a commit that referenced this issue Feb 13, 2022
Issue #18 shows that the current wording is not intuitive to all users. An example could help.
@peacefulseeker
Copy link

+1 to @avryhof' said. Removing media references from the export JSON file would help a lot, eliminating the need
of manual editing of the exported JSON file. So with null value for media-related properties the plugins get imported just fine(without media source within the plugin, obviously)

@wfehr
Copy link
Contributor

wfehr commented Apr 25, 2024

This might be resolved with the changes from #20.
With now released version 1.0.2 you can define custom serializer handling which also enables custom processing for filer-images, e.g. ignoring them, creating a default image on import or transferring images with base64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants