Skip to main content

pypi coverage python django djangocms

django CMS Transfer is an experimental package that allows you to export and import plugin data from a page or a placeholder. It does not support foreign key relations and won’t import/export related data, such as media.

preview.gif

Documentation

The setting DJANGO_CMS_TRANSFER_SERIALIZER allows registration of a custom JSON serializer. An example use case would be subclassing Django’s built-in Python serializer to base64-encode inline image data.

See REQUIREMENTS in the setup.py file for additional dependencies:

Installation

For a manual install:

  • run pip install djangocms-transfer

  • add djangocms_transfer to your INSTALLED_APPS

Version Compatibility

For django CMS 4.0 or later, you must use djangocms-transfer 2.0 or later.

For django CMS 3.7 through 3.11 use versions 1.x of djangocms-transfer.

How to Use

To export/import a page, click on the “Page” menu on the toolbar and select your desired choice.

To export/import a plugin, Open the “Structure board”, click on the dropdown menu for the specific plugin and select your choice.

Customization

Following settings are available:

  • DJANGOCMS_TRANSFER_PROCESS_EXPORT_PLUGIN_DATA:

    Enables processing of plugin instances prior to serialization, e.g. myapp.module.function.

  • DJANGOCMS_TRANSFER_PROCESS_IMPORT_PLUGIN_DATA:

    Enables processing of plugin instances prior to saving, e.g. myapp.module.function. For example: set default-values for ForeignKeys (images for django_filer, ..)

As an example the combination of _PROCESS_EXPORT_PLUGIN_DATA and _PROCESS_IMPORT_PLUGIN_DATA lets you export and import the data between different systems while setting the contents as you need it:

# settings.py
.._PROCESS_EXPORT_PLUGIN_DATA = "myapp.some.module.export_function"
.._PROCESS_IMPORT_PLUGIN_DATA = "myapp.some.module.import_function"

# custom functions
def export_function(plugin, plugin_data):
    # remove child-plugins which can't be handled
    if plugin.parent_id and plugin.parent.plugin_type == "SomeParentPlugin":
        return None
    # change data
    if plugin.plugin_type == "SomePlugin":
        plugin_data["data"].update({
            "some_field": "TODO: change me",
        })
    return plugin_data

def import_function(plugin, plugin_data):
    some_related_fallback_object = MyModel.objects.first()
    for field in plugin._meta.fields:
        # example of setting a default value for a related field
        if isinstance(field, ForeignKey):
            plugin_value = getattr(plugin, field.attname)
            raw_value = plugin_data[field.name]
            if (
                field.related_model == MyModel
                # related object is referenced, but does not exist
                and plugin_value is None and raw_value is not None
            ):
                setattr(plugin, field.name, some_related_fallback_object)
    # There is no guarantee on whether djangocms-transfer saves the
    # plugin. It is recommended to do this yourself in case you changed
    # the plugin.
    plugin.save()

Running Tests

You can run tests by executing:

python -m venv env
source env/bin/activate
pip install -r tests/requirements/dj51_cms41.txt
coverage run -m pytest

Contribute to this project and win rewards

Because this is an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We’ll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We’re grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

Metadata

Release files for djangocms-transfer 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangocms-transfer 2.0.1
File Size Uploaded
djangocms_transfer-2.0.1.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangocms-transfer 2.0.1
File Interpreter ABI Platform
djangocms_transfer-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.4 kB

Release files / djangocms_transfer-2.0.1.tar.gz

Download URL djangocms_transfer-2.0.1.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b9018d09f17ed5c3bf19cbd09a5b59e6260b0f7bce0e1c040b3c90415a4bff85
BLAKE2b-256 checksum
How to use checksums
7f053ad9e1beda88efab83f4b226c9d32dcea045d340252501664d800066113c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / djangocms_transfer-2.0.1-py3-none-any.whl

Download URL djangocms_transfer-2.0.1-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
009a6588301649c4447fc568ed2d2a5c30dfb0241472b9d2fc71ef794ccdb6b0
BLAKE2b-256 checksum
How to use checksums
8d8295efee616d0ead378e9ed4884f6070ec3d98001550615faba736b0c440e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page