Skip to main content

django CMS Transfer

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

This version supports django CMS 4.1 and later.

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.

Transfer format

File and browser clipboard exports use the same versioned JSON object:

{"format": "djangocms-transfer", "version": 1, "kind": "plugin", "plugins": [...]}

kind is plugin, placeholder, or page. Page exports contain placeholders instead of plugins; each entry has placeholder (the slot name) and plugins. File imports into a page preserve these slot names. Page exports imported into the browser clipboard combine all slots into a single clipboard placeholder, ready for the normal Paste action.

Both import paths also recognize legacy JSON lists. Lists of plugin records are treated as a plugin tree when there is one root, or as a placeholder otherwise; a legacy single-root placeholder cannot be distinguished from a plugin export. Lists of {"placeholder": ..., "plugins": [...]} records are treated as page exports. Export-hook null plugin rows are skipped. Mixed or malformed records are rejected, and an unsupported explicit format/version never falls back to legacy detection. Empty legacy lists are accepted as empty placeholder file imports; empty content cannot replace the browser clipboard.

Browser clipboard

In edit mode, copying or cutting a plugin (including its children), or copying a whole placeholder, also writes its transfer JSON to the browser clipboard. To transfer it to another instance, open that instance’s administration menu in the toolbar and choose “Import clipboard from browser…”. This replaces your django CMS clipboard; use the normal Paste action to insert the content wherever it is allowed.

Clipboard content is validated on import, including installed plugin types and your permission to add them. Invalid content leaves your CMS clipboard unchanged. File and clipboard imports both call the plugin model’s full_clean() before saving. Validation and normalization of plugin data, including JSON configuration, belong in model fields, their validators, or Model.clean(). Plugin editing forms are not used during import. CMS identity and tree fields are supplied by the destination and excluded from field validation. Rich-text sanitization follows the plugin’s own save behavior, just as when editing that plugin normally; this package does not impose a separate HTML policy. Export-hook None rows are skipped by both import paths. Both instances need django CMS Transfer installed. Related objects and media have the same limitations as file export/import.

Browser clipboard access requires HTTPS (or localhost) and browser permission. If the browser clipboard cannot be updated, the normal CMS copy still succeeds and a message explains that browser copying failed.

Customization

Following settings are available:

  • DJANGOCMS_TRANSFER_MODE (default: "all"):

    • "all" enables file export/import and browser clipboard support.

    • "files-only" disables browser clipboard copying and importing, including its toolbar menu item and endpoint. File export/import remains available.

    • "clipboard-only" enables browser clipboard support and removes file import/export menus for pages, placeholders, and plugins.

    Normal django CMS copy/paste remains available in all modes. This setting replaces DJANGOCMS_TRANSFER_BROWSER_CLIPBOARD; replace the former value False with DJANGOCMS_TRANSFER_MODE = "files-only".

  • DJANGOCMS_TRANSFER_MAX_CLIPBOARD_SIZE (default: 20971520, 20 MiB):

    Maximum size of a browser clipboard upload in bytes; None disables this limit. Browser imports use multipart file uploads, so they can exceed Django’s DATA_UPLOAD_MAX_MEMORY_SIZE JSON-body limit. Oversized uploads report an error and preserve the CMS clipboard. File import remains available for larger transfers, subject to the site’s web-server limits.

  • 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 after validation and saving, e.g. myapp.module.function. The hook runs inside the import transaction; save any changes made by the hook explicitly.

    Compatibility change: imports now reject missing related objects before this hook runs. Hooks can no longer repair references to objects absent from the destination site. Create or map related objects before importing, and put validation or normalization needed before saving in model fields or Model.clean().

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
DJANGOCMS_TRANSFER_PROCESS_EXPORT_PLUGIN_DATA = "myapp.some.module.export_function"
DJANGOCMS_TRANSFER_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):
    if plugin.plugin_type == "SomePlugin":
        plugin.some_field = plugin_data["some_field"].strip()
        # Validate and save changes made after the initial import save.
        plugin.full_clean()
        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.1.0

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.1.0
File Size Uploaded Provenance Actions
djangocms_transfer-2.1.0.tar.gz 39.1 kB Without provenance Details for djangocms_transfer-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 64.2 kB

Release files / djangocms_transfer-2.1.0.tar.gz

Download URL djangocms_transfer-2.1.0.tar.gz
Size 39.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6d7384f6e8a2e195a5143fffdc7f6621cc69bb9ef978db77c43a75e8ac9d3bb1
BLAKE2b-256 checksum
How to use checksums
a469ab740b217f8b2d3bbde7156d06ee4c25302e3d8f8cca4ee73edc4370ac73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL djangocms_transfer-2.1.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df79de6066bad4221bbb659e54ef063aa9c00144e942eb3cf84eb017d1c786a0
BLAKE2b-256 checksum
How to use checksums
33e9b6a95f698beec3616dff66297c594c25fa2720722dff8a78d08d7e79cb9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for djangocms-transfer 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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