django-cms/djangocms-history

Provides undo/redo functionality for django CMS operations

addon
cms
django
django-cms
python

django CMS History

pypi coverage PyPI - Python Version PyPI - Django Versions from Framework Classifiers PyPI - django CMS Versions from Framework Classifiers

django CMS History is an addon application to provide undo/redo functionality in django CMS, by maintaining content history.

Some of the functionality in this application was previously included in django CMS itself. However, it became apparent that some users did not want it, and some wanted functionality that worked differently.

In keeping with the django CMS philosophy of maintaining only core CMS functionality as part of the package itself, history management was removed from django CMS in version 3.4 and has been spun off into an independent application.

django CMS History has been rewritten from the ground up. It will continue to be developed. New functionality and improvements will be introduced in future releases.

image

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.

Documentation

Version support

djangocms-history 3.x supports Python 3.9 through 3.13, Django 4.2, 5.2, 6.0 and 6.1, and django CMS 4.1, 5.0 and 5.1. If you are using django CMS 3.x, use djangocms-history 2.x.

The supported Python, Django and django CMS versions are shown by the badges at the top of this page (latest release read directly from the published PyPI classifiers). The latest supported versions of the master branch are declared in pyproject.toml; the tested combinations are defined in tox.ini and tests/requirements.

Installation

For a manual install:

  • run pip install djangocms-history
  • add djangocms_history to your INSTALLED_APPS
  • run python manage.py migrate djangocms_history

:::: warning ::: title Warning :::

Upgrading from djangocms-history 2.x: history records created with django CMS 3.x cannot be replayed against the plugin tree of django CMS 4 and later. All existing history records are deleted by the migrations of version 3.0. Since the undo window is 24 hours, this only affects operations performed right before the upgrade. ::::

Configuration

Once installed, django CMS History will make new options available to the web content manager. These will be visible in the django CMS toolbar when managing content that is supported by the application.

In-place updates

On django CMS 5.1 and later, undo and redo update the structure board in place (through the data bridge the endpoints return), preserving scroll position and board state. On earlier versions the page is reloaded after each undo/redo instead.

History scope and limitations

History records plugin operations rather than arbitrary model or page changes. Undo/redo is available for the last 24 hours and for one content origin per user session. Editing another page supersedes the previous page\'s history; another user\'s edit supersedes history only when it affects the same content. Changing a plugin with a many-to-many relation clears the history for that content because the change cannot be restored reliably.

Operations older than 24 hours are ignored, but age alone does not immediately delete or archive their database rows. Superseded operations and operations from an earlier login session are retired when the corresponding cleanup path runs.

Retiring operations: archive or delete

By default retired operations are deleted outright. If you would rather retain them for inspection, enable archiving:

DJANGOCMS_HISTORY_ARCHIVE_OPERATIONS = True

Archived operations are flagged with is_archived=True and are still never used by undo/redo. They are not durable audit records: deleting related users, placeholders or other referenced content may delete them through database cascades. To remove archived operations later and reclaim database space, run:

python manage.py purge_archived_operations

The command supports --days N (only purge archived operations older than N days) and --dry-run (report what would be deleted without deleting).

djangocms-versioning

When djangocms-versioning is installed, undo/redo only operates on content that is editable, i.e. on draft versions. Once a version has been published, operations recorded on its draft can no longer be undone or redone; the toolbar buttons are disabled and the endpoints refuse to modify the published content.

Running Tests

The test suite uses pytest (with pytest-django). You can run tests by executing:

python -m venv env
source env/bin/activate
pip install -r tests/requirements/dj52_cms50.txt -e .
pytest

Run with djangocms-versioning installed:

pip install djangocms-versioning
VERSIONING=1 pytest
Stars
28
100.00% more than last month
Forks
12
Open Issues
3