-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improved simple history installation guide
- Loading branch information
1 parent
bec3555
commit 87a618c
Showing
1 changed file
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
--- | ||
title: django-simple-history | ||
order: 0 | ||
description: Integration with django-simple-history. | ||
description: Learn how to integrate django-simple-history with Django Unfold admin panel to track and display model history changes for seamless version control and change tracking. | ||
--- | ||
|
||
# django-simple-history | ||
|
||
To make this application work, add `unfold.contrib.simple_history` into `settings.py` in `INSTALLED_APPS` variable before right after `unfold`. This app should ensure that templates coming from django-simple-history are overridden by Unfold. | ||
To make this application work, add `unfold.contrib.simple_history` to the `INSTALLED_APPS` variable in `settings.py`, placing it after `unfold` but before `simple_history`. This app ensures that templates from django-simple-history are overridden by Unfold. | ||
|
||
```python | ||
# settings.py | ||
|
||
INSTALLED_APPS = [ | ||
"unfold", | ||
# ... | ||
"unfold.contrib.simple_history", | ||
# ... | ||
"simple_history", | ||
] | ||
``` | ||
|
||
Below you can find an example of how to use Unfold with django-simple-history. The important part is to inherit from `SimpleHistoryAdmin` and `unfold.adminModelAdmin`. | ||
|
||
```python | ||
# admin.py | ||
|
||
from django.contrib import admin | ||
from django.contrib.auth import get_user_model | ||
|
||
from simple_history.admin import SimpleHistoryAdmin | ||
from unfold.admin import ModelAdmin | ||
|
||
User = get_user_model() | ||
|
||
|
||
@admin.register(User) | ||
class UserAdmin(SimpleHistoryAdmin, ModelAdmin): | ||
pass | ||
``` |