Registry / database / django-simple-history

django-simple-history

JSON →
library3.13.0pypypi✓ verified 30d ago

django-simple-history is a Django library that provides an easy way to store historical records for your Django models, allowing you to view and revert changes through the admin site. It is actively maintained with frequent releases, currently at version 3.11.0.

pip install django-simple-history
INSTALL
IMPORT
SIG · DJANGO-SIMPLE-HIST
D
django-simple-history
databasepythonv3.13.0
Install
3.6s avg
Import
877ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.918s · 66.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.6s · import 0.836s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HistoricalRecords
✓ from simple_history.models import HistoricalRecords
✗ from simple_history import HistoricalRecords
HistoricalRecords is defined within the models submodule.
SimpleHistoryAdmin
✓ from simple_history.admin import SimpleHistoryAdmin
✗ from simple_history.models import SimpleHistoryAdmin
SimpleHistoryAdmin is specifically for integrating with Django's admin interface.
register
✓ from simple_history import register
✗ from simple_history.models import register
The top-level `register` function for dynamic model registration is directly under the simple_history package.

This quickstart demonstrates how to add historical tracking to a Django model by simply adding a `history = HistoricalRecords()` field. Remember to add `simple_history` to your `INSTALLED_APPS` and run `makemigrations`/`migrate`. For admin integration, register your model with `SimpleHistoryAdmin`.

import os from django.db import models from simple_history.models import HistoricalRecords # Ensure 'simple_history' is in INSTALLED_APPS in your Django settings. # Example: INSTALLED_APPS = ['...', 'simple_history', 'myapp'] class Product(models.Model): name = models.CharField(max_length=200) price = models.DecimalField(max_digits=10, decimal_places=2) history = HistoricalRecords() def __str__(self): return self.name # To see history in the Django admin: # 1. Add 'simple_history' to INSTALLED_APPS. # 2. In myapp/admin.py: # from django.contrib import admin # from simple_history.admin import SimpleHistoryAdmin # from .models import Product # admin.site.register(Product, SimpleHistoryAdmin)
Debug
Known issues
breakingThe `simple_history_admin_list.display_list()` method was removed. If you were using this for custom admin views, it will break.
fix
Review your admin customizations and update them to use current Django admin patterns or alternative methods for displaying history lists. Consult the official documentation for `SimpleHistoryAdmin`.
affects: >=3.9.0
breakingSupport for Django 3.2 has been officially dropped. Projects using django-simple-history 3.7.0 or newer must upgrade their Django version.
fix
Upgrade your Django project to version 3.6 or newer. For versions 3.7.0+, Django 3.2 is no longer supported.
affects: >=3.7.0
gotchaWhen defining `HistoricalRecords`, it must be instantiated (e.g., `history = HistoricalRecords()`). Forgetting the parentheses is a common error.
fix
Always use `HistoricalRecords()` with parentheses. If you use `HistoricalRecords` without them, it will result in incorrect behavior or errors as you're assigning the class itself, not an instance.
affects: <all>
gotchaHistorical records for Many-to-Many (M2M) relationships require specific handling and are not tracked by default with simple `HistoricalRecords()`. Support for M2M with inheritance and signals was improved in 3.3.0.
fix
For M2M history, you generally need to track changes on the 'through' model or implement custom logic. Refer to the official `django-simple-history` documentation on 'Historical Many-to-Many' relationships for detailed guidance.
affects: <all>
gotchaThe repository moved from 'jazzband' to 'django-commons'. While not a direct code-breaking change, old documentation links, issue trackers, or GitHub references might be outdated.
fix
Ensure you are referencing the correct GitHub repository (`github.com/django-commons/django-simple-history`) for up-to-date information, issues, and contributions.
affects: >=3.10.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'simple_history'
The 'django-simple-history' package is either not installed in the active Python environment or is installed in a different environment than the one Django is using.
fix
Ensure the library is installed using pip: `pip install django-simple-history` and that your virtual environment is activated and correctly configured for your project.
Django Simple History not recording changes for bulk_create or queryset.update()
Django-simple-history relies on `post_save` signals to record history. Bulk operations like `bulk_create` and `QuerySet.update()` do not emit these signals, so history is not automatically saved.
fix
For `bulk_create`, use `simple_history.utils.bulk_create_with_history`. For `QuerySet.update()`, iterate over the queryset and call `save()` on each instance, or use a custom utility function that manually creates historical records.
AttributeError: 'HistoryManager' object has no attribute '_meta' / AttributeError: 'Historical<ModelName>' object has no attribute '<related_field>'
Historical records and the `HistoryManager` are not regular model instances or managers; they represent a specific past state or a collection of historical states. Direct access to related objects or certain `_meta` attributes may not be available or function as expected.
fix
To access related objects from a historical record, you usually need to retrieve the actual instance using `historical_record.instance` first, or specifically define `HistoricForeignKey` or `HistoricOneToOneField` if relationships need to be honored at a historical point in time.
AttributeError: type object 'SimpleHistoryAdmin' has no attribute '_meta'
This error often occurs when `SimpleHistoryAdmin` is incorrectly registered or subclassed, leading Django to try and treat `SimpleHistoryAdmin` itself as a model with `_meta` attributes. This can happen if you pass `SimpleHistoryAdmin` directly to `admin.site.register()` without a model, or if there's an issue in your `admin.py` with how you define or register your admin classes.
fix
Ensure `SimpleHistoryAdmin` is used as a mixin or directly inherited by your model's admin class, and that it's correctly registered with your model. For example: `from simple_history.admin import SimpleHistoryAdmin; @admin.register(MyModel) class MyModelAdmin(SimpleHistoryAdmin): pass` or `admin.site.register(MyModel, MyModelAdmin)`.
Upgrade
Version history
3.13.0latest on PyPI · released Jul 22, 2026
Audit
Dependencies
DjangorequiredCore framework dependency; requires Django>=3.2.
Agent activity
9 hits · last 30 days
node
8
Resources
django-simple-history — pip install django-simple-history · libregistry