Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
7861dae
Show field values before deletion in the admin
aleh-rymasheuski Jun 29, 2022
95929cd
Add assertions for msg_short
aleh-rymasheuski Jun 29, 2022
93907b7
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jul 4, 2022
3e04444
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jul 11, 2022
2f914c1
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jul 25, 2022
f68af30
Pin python-dateutil>=2.7.0 (#401)
aleh-rymasheuski Jul 27, 2022
68cde8f
Prepare release 2.1.1
hramezani Jul 27, 2022
a24b79a
Display timestamps in server timezone (#404)
aleh-rymasheuski Aug 1, 2022
4ed056b
[pre-commit.ci] pre-commit autoupdate (#405)
pre-commit-ci[bot] Aug 1, 2022
1cd7d98
Confirm Django 4.1 support (#406)
hramezani Aug 3, 2022
830152f
Fix code block in usage.rst
hramezani Aug 4, 2022
eb5e873
Add django-upgrade to pre-commit-config.yaml (#411)
hramezani Aug 8, 2022
a00d2c2
[pre-commit.ci] pre-commit autoupdate (#413)
pre-commit-ci[bot] Aug 8, 2022
c13d6ec
[pre-commit.ci] pre-commit autoupdate (#416)
pre-commit-ci[bot] Aug 15, 2022
18868aa
Handle port in `remote_addr`
hramezani Aug 16, 2022
174605d
docs(readme): update the release section (#351)
Linkid Aug 17, 2022
57423fc
Add required Python and Django version to setup.py (#419)
hramezani Aug 18, 2022
777bd53
Add serialized object field (#412)
sum-rock Aug 21, 2022
527f870
[pre-commit.ci] pre-commit autoupdate (#422)
pre-commit-ci[bot] Aug 29, 2022
93602bd
[pre-commit.ci] pre-commit autoupdate (#423)
pre-commit-ci[bot] Sep 5, 2022
acada9e
[pre-commit.ci] pre-commit autoupdate (#425)
pre-commit-ci[bot] Sep 12, 2022
fb90112
[pre-commit.ci] pre-commit autoupdate (#430)
pre-commit-ci[bot] Sep 19, 2022
d74c118
Added verbose field name in admin (#428)
rptmat57 Sep 20, 2022
a56d0e6
added fix for OneToOneRel error happening in case of Polymorphic mode…
rpsatorugit Sep 21, 2022
0f57525
Support search by custom USERNAME_FIELD (#432)
aleh-rymasheuski Sep 21, 2022
993cd84
[pre-commit.ci] pre-commit autoupdate (#435)
pre-commit-ci[bot] Sep 26, 2022
487b8ab
Remove unnecessary code in `created` method. (#438)
2ykwang Oct 5, 2022
c04f535
[pre-commit.ci] pre-commit autoupdate (#440)
pre-commit-ci[bot] Oct 10, 2022
90ce363
[pre-commit.ci] pre-commit autoupdate (#442)
pre-commit-ci[bot] Oct 17, 2022
aa6d977
Update pyupgrade and django-upgrade pre-commit hooks
hramezani Nov 1, 2022
8fe776a
Option to disable logging on raw save and via context manager (#446)
robinharms Nov 4, 2022
f71699a
Added ACCESS action and enabled logging of object accesses (#436)
simonkern Nov 7, 2022
36eaaaa
Confirm Python 3.11 support (#447)
hramezani Nov 7, 2022
2b0bc9e
Replace the `django.utils.timezone.utc` by `datetime.timezone.utc` (#…
hramezani Nov 7, 2022
227b0d9
Prepare release 2.2.0 (#434)
hramezani Nov 7, 2022
a6ea91f
[pre-commit.ci] pre-commit autoupdate (#451)
pre-commit-ci[bot] Nov 14, 2022
96275d5
Add `serialize_data` setting (#452)
2ykwang Nov 15, 2022
1ba3bd9
Disallow changing or deleting log entries (#449)
aleh-rymasheuski Nov 21, 2022
e23b091
Replace `pkg_resources` with `importlib` solution (#450)
hramezani Nov 21, 2022
4cdc756
FIX: Parsing client IPv6 address when a proxy is involved (#457)
aqeelat Nov 22, 2022
b4dda75
update readme link (#460)
Arhell Nov 28, 2022
2a93c20
Prepare release 2.2.1 (#459)
hramezani Nov 28, 2022
1674aca
[pre-commit.ci] pre-commit autoupdate (#462)
pre-commit-ci[bot] Nov 28, 2022
bfaeeab
update docs folder link (#465)
Arhell Dec 1, 2022
caf5daa
[pre-commit.ci] pre-commit autoupdate (#466)
pre-commit-ci[bot] Dec 6, 2022
cd1ba3d
[pre-commit.ci] pre-commit autoupdate (#473)
pre-commit-ci[bot] Dec 13, 2022
27f57a5
Fix LogEntry.changes_dict() to return {} when json.loads() returns No…
tykling Dec 13, 2022
703e3e4
Complete translation with gettext_lazy (#474)
ZahraEbrahimi01 Dec 14, 2022
8e496aa
- using changes_dict to fix potential TypeError when changes are None…
rptmat57 Dec 15, 2022
971a4f4
- fixed unused import
rptmat57 Dec 15, 2022
a733cd0
feat: Make timestamp in LogEntry overwritable (#478)
aqeelat Dec 19, 2022
63c8882
[pre-commit.ci] pre-commit autoupdate (#482)
pre-commit-ci[bot] Dec 19, 2022
bc6d393
Added support for Correlation ID
aqeelat Dec 23, 2022
6996e1c
Revert "Disallow changing or deleting log entries" (#496)
aleh-rymasheuski Jan 16, 2023
2595a36
Prepare release 2.2.2 (#497)
hramezani Jan 17, 2023
c65a0b2
Merge upstream 2.1.1 and partial 2.2.0
aleh-rymasheuski Jul 13, 2023
29d92e7
Merge "serialized_data" feature
aleh-rymasheuski Jul 13, 2023
614f4bc
Merge another part of upstream 2.2.0
aleh-rymasheuski Jul 13, 2023
c422dd1
Merge upstream version 2.2.0
aleh-rymasheuski Jul 13, 2023
c95a0c1
Merge upstream version 2.2.1
aleh-rymasheuski Jul 13, 2023
779a751
Skip upstream version 2.2.2
aleh-rymasheuski Jul 13, 2023
1176968
Merge overwritable timestamp from upstream
aleh-rymasheuski Jul 13, 2023
addaaa7
Merge cid from upstream
aleh-rymasheuski Jul 13, 2023
57cd23e
Merge upstream changes prior to JSON migration
aleh-rymasheuski Jul 13, 2023
d73e94c
[pre-commit.ci] pre-commit autoupdate (#485)
pre-commit-ci[bot] Dec 28, 2022
4cde569
Run django main tests on Python >= 3.10 (#499)
hramezani Jan 19, 2023
667a990
[pre-commit.ci] pre-commit autoupdate (#504)
pre-commit-ci[bot] Jan 31, 2023
8e0870f
[pre-commit.ci] pre-commit autoupdate (#507)
pre-commit-ci[bot] Feb 9, 2023
a65204a
[pre-commit.ci] pre-commit autoupdate (#516)
pre-commit-ci[bot] Feb 20, 2023
3568196
Fix GitHub actions deprecations (#520)
aleh-rymasheuski Apr 1, 2023
7f6d646
[pre-commit.ci] pre-commit autoupdate (#521)
pre-commit-ci[bot] Apr 4, 2023
87c4583
[pre-commit.ci] pre-commit autoupdate (#523)
pre-commit-ci[bot] May 8, 2023
2365cee
[pre-commit.ci] pre-commit autoupdate (#527)
pre-commit-ci[bot] May 9, 2023
9093e61
Confirm Django 4.2 support (#529)
hramezani May 25, 2023
816b837
[pre-commit.ci] pre-commit autoupdate (#534)
pre-commit-ci[bot] Jun 24, 2023
2630a0e
Drop Django 4 support (#540)
hramezani Jul 3, 2023
2c1a3e7
[pre-commit.ci] pre-commit autoupdate (#541)
pre-commit-ci[bot] Jul 3, 2023
03920f2
Merge tox & CI changes from upstream master
aleh-rymasheuski Jul 13, 2023
682e8e2
Add null=True to LogEntry.cid field
aleh-rymasheuski Jul 19, 2023
47188b4
Stop deleting log entries in log_create
aleh-rymasheuski Aug 31, 2023
ab65364
Set history delete_related to False by default (#557)
aleh-rymasheuski Aug 24, 2023
408a105
Allow cascade deletion of auditlog entries (#556)
aleh-rymasheuski Aug 27, 2023
ca3806f
Drop support for Python 3.7 (#546)
hramezani Jul 13, 2023
0807b8f
Allow @auditlog.register with no parentheses
aleh-rymasheuski Oct 24, 2023
e3f547c
Adding Custom Pre- and Post- Log Hooks (#483)
aqeelat Dec 27, 2022
e3f6c02
Modify ``change`` field to be a json field. (#407)
sum-rock Dec 28, 2022
eebde3a
Convert AUDITLOG_EXCLUDE_TRACKING_MODELS to tuple before concatenate …
aivarsk Dec 29, 2022
f6a1c9c
Fix repr of a json field in field changes (#489)
CleitonDeLima Dec 30, 2022
60760ee
raise AuditLogRegistrationError on invalid app in settings (#492)
Jan 3, 2023
abb9c25
Always call set_actor (#484)
Jan 4, 2023
df4922e
Add ability to globally exclude fields by name on all models (#498)
darkpixel Jan 20, 2023
02aeaea
Make M2M changes comply with JSONField properly (#514)
josefdlange Feb 15, 2023
3c860f4
fixed getting field's verbose_name (#508)
AllYouZombies May 17, 2023
f35d8f0
Fix unnecessary log when adding already existed m2m record (#535)
firtk Jun 21, 2023
1949b62
Fix a bug in `serialized_data` with F expressions (#544)
hramezani Jul 13, 2023
e5e1e3b
[pre-commit.ci] pre-commit autoupdate (#547)
pre-commit-ci[bot] Jul 17, 2023
dc5edf5
feat: collect all models including auto created ones and excluding no…
Aug 9, 2023
3c6d86f
feat: give users the option to run the json migration asyncly (#495)
Aug 13, 2023
04fae7f
Confirm Python 3.12 support (#572)
jgillard Nov 2, 2023
8aaf5a1
chore: add a check arg to the migration command (#563)
Sep 13, 2023
d606aeb
[pre-commit.ci] pre-commit autoupdate (#562)
pre-commit-ci[bot] Sep 11, 2023
8802cbe
[pre-commit.ci] pre-commit autoupdate (#564)
pre-commit-ci[bot] Sep 18, 2023
1b8e78a
fix: don't set the correlation_id if the `AUDITLOG_CID_GETTER` is `No…
Sep 20, 2023
284666c
Update postgres to 13 (#568)
hramezani Sep 26, 2023
e7684fc
Update pre-commit repos (#569)
hramezani Sep 26, 2023
757aa99
fix: change verbose_name in changes_text migration (#571)
Oct 5, 2023
188891a
[pre-commit.ci] pre-commit autoupdate (#579)
pre-commit-ci[bot] Nov 2, 2023
0550ea7
use contextvar instead of threadlocal (#581)
hamedsh Nov 6, 2023
60caa0a
Prepare release 3.0.0-beta.3 (#587)
hramezani Nov 14, 2023
3054882
[pre-commit.ci] pre-commit autoupdate (#594)
pre-commit-ci[bot] Dec 11, 2023
a23195d
[pre-commit.ci] pre-commit autoupdate (#595)
pre-commit-ci[bot] Dec 19, 2023
1196695
Confrim Django 5.0 and drop django 4.1 (#598)
hramezani Dec 29, 2023
3daa5b5
Prepare release 3.0.0-beta.4 (#599)
hramezani Jan 3, 2024
18eeb9e
[pre-commit.ci] pre-commit autoupdate (#601)
pre-commit-ci[bot] Jan 9, 2024
b671792
fix: avoid exception in changes_display_dict when model is missing (#…
ppmathis Feb 13, 2024
3f5a07c
Keep GitHub Actions up to date with GitHub's Dependabot (#618)
cclauss Mar 20, 2024
26971d1
Bump the github-actions group with 4 updates (#619)
dependabot[bot] Mar 20, 2024
6165578
Correcting a typo in usage.rst (#615)
plmrn Mar 20, 2024
49dc9bf
Disable logging remote IP address (#620)
Nathan-Cohen Mar 31, 2024
4677a70
Add note about V3 to readme (#626)
hramezani Apr 7, 2024
3c59b6f
Fixed manuall logging when model is not registered (#627)
hramezani Apr 12, 2024
64ec0c9
Prepare release 3.0.0 (#629)
hramezani Apr 12, 2024
bec1c2d
Fixed problem when setting `django.db.models.functions.Now()` in `Dat…
hramezani Apr 29, 2024
efd0b7c
Update postgres to 14 (#649)
hramezani May 27, 2024
ec43e00
update docs (#662)
mohsiniscoding Aug 1, 2024
40523be
Added --no-color args in test migration (#670)
CleitonDeLima Oct 1, 2024
242a333
Added remote port (#671)
CleitonDeLima Oct 7, 2024
8c76642
Drop Python 3.8 support (#678)
hramezani Oct 17, 2024
d9a7c6a
Replace index_together with indexes
MercymeIlya Oct 21, 2025
f6fb74d
Confirm Django 5.1 support and drop Django 3.2 support. (#677)
hramezani Oct 17, 2024
f548510
Update pre-commit (#679)
hramezani Oct 17, 2024
42b913c
Sync django query and postgres query (#653)
GreatBahram Jun 12, 2024
11d5ae6
Add Python 3.13 support (#697)
hramezani Jan 29, 2025
fc6bdc6
Fix Expression test compatibility for Django 6.0+ (#759)
2ykwang Sep 24, 2025
82ad79a
don't run tests on django main version, update fork maintainer
MercymeIlya Oct 21, 2025
49da776
run tests for django 5.2
MercymeIlya Dec 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keep GitHub Actions up to date with GitHub's Dependabot...
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: weekly
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.9'

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: release-${{ hashFiles('**/setup.py') }}
Expand All @@ -50,4 +50,4 @@ jobs:
with:
user: jazzband
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
repository_url: https://jazzband.co/projects/django-auditlog/upload
repository-url: https://jazzband.co/projects/django-auditlog/upload
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

services:
postgres:
image: postgres:12
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432/tcp
- 5432/tcp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-retries 10

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
Expand All @@ -64,6 +64,6 @@ jobs:
TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }}

- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
name: Python ${{ matrix.python-version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ venv.bak/

### JetBrains
.idea/
.vscode/
19 changes: 12 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
---
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.8
language_version: python3.9
args:
- "--target-version"
- "py37"
- "py39"
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
rev: "7.3.0"
hooks:
- id: flake8
args: ["--max-line-length", "110"]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py39-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.25.0
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]
112 changes: 112 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,117 @@
# Changes

## Next Release

#### Improvements

- Add Python 3.13 support. ([#671](https://github.com/jazzband/django-auditlog/pull/671))
- feat: Added `LogEntry.remote_port` field. ([#671](https://github.com/jazzband/django-auditlog/pull/671))
- Drop Python 3.8 support. ([#678](https://github.com/jazzband/django-auditlog/pull/678))
- Confirm Django 5.1 support and drop Django 3.2 support. ([#677](https://github.com/jazzband/django-auditlog/pull/677))

#### Fixes

- Fixed problem when setting `django.db.models.functions.Now()` in `DateTimeField` ([#635](https://github.com/jazzband/django-auditlog/pull/635))

## 3.0.0 (2024-04-12)

#### Fixes

- Fixed manuall logging when model is not registered ([#627](https://github.com/jazzband/django-auditlog/pull/627))

#### Improvements
- feat: Excluding ip address when `AUDITLOG_DISABLE_REMOTE_ADDR` is set to True ([#620](https://github.com/jazzband/django-auditlog/pull/620))


## 3.0.0-beta.4 (2024-01-02)

#### Improvements

- feat: If any receiver returns False, no logging will be made. This can be useful if logging should be conditionally enabled / disabled ([#590](https://github.com/jazzband/django-auditlog/pull/590))
- Django: Confirm Django 5.0 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))
- Django: Drop Django 4.1 support ([#598](https://github.com/jazzband/django-auditlog/pull/598))

## 3.0.0-beta.3 (2023-11-13)

#### Improvements

- Python: Confirm Python 3.12 support ([#572](https://github.com/jazzband/django-auditlog/pull/572))
- feat: `thread.local` replaced with `ContextVar` to improve context managers in Django 4.2+

## 3.0.0-beta.2 (2023-10-05)

#### Breaking Changes
- feat: stop deleting old log entries when a model with the same pk is created (i.e. the pk value is reused) ([#559](https://github.com/jazzband/django-auditlog/pull/559))

#### Fixes
* fix: don't set the correlation_id if the `AUDITLOG_CID_GETTER` is `None` ([#565](https://github.com/jazzband/django-auditlog/pull/565))

## 3.0.0-beta.1

#### Breaking Changes

- feat: Change `LogEntry.change` field type to `JSONField` rather than `TextField`. This change include a migration that may take time to run depending on the number of records on your `LogEntry` table ([#407](https://github.com/jazzband/django-auditlog/pull/407))([#495](https://github.com/jazzband/django-auditlog/pull/495))
- feat: Set `AuditlogHistoryField.delete_related` to `False` by default. This is different from the default configuration of Django's `GenericRelation`, but we should not erase the audit log of objects on deletion by default. ([#557](https://github.com/jazzband/django-auditlog/pull/557))
- Python: Drop support for Python 3.7 ([#546](https://github.com/jazzband/django-auditlog/pull/546))

#### Improvements

- Changes the view when it has changes in fields `JSONField`. The `JSONField.encoder` is assigned to `json.dumps`. ([#489](https://github.com/jazzband/django-auditlog/pull/489))
- feat: Added support for Correlation ID. ([#481](https://github.com/jazzband/django-auditlog/pull/481))
- feat: Added pre-log and post-log signals. ([#483](https://github.com/jazzband/django-auditlog/pull/483))
- feat: Make timestamp in LogEntry overwritable. ([#476](https://github.com/jazzband/django-auditlog/pull/476))
- feat: Support excluding field names globally when ```AUDITLOG_INCLUDE_ALL_MODELS``` is enabled. ([#498](https://github.com/jazzband/django-auditlog/pull/498))
- feat: Improved auto model registration to include auto-created models and exclude non-managed models, and automatically register m2m fields for models. ([#550](https://github.com/jazzband/django-auditlog/pull/550))

#### Fixes

- fix: Make sure `LogEntry.changes_dict()` returns an empty dict instead of `None` when `json.loads()` returns `None`. ([#472](https://github.com/jazzband/django-auditlog/pull/472))
- fix: Make log entries read-only in the admin. ([#449](https://github.com/jazzband/django-auditlog/pull/449), [#556](https://github.com/jazzband/django-auditlog/pull/556)) (applied again after being reverted in 2.2.2)
~~- fix: revert [#449](https://github.com/jazzband/django-auditlog/pull/449) "Make log entries read-only in the admin" as it breaks deletion of any auditlogged model through the admin when `AuditlogHistoryField` is used. ([#496](https://github.com/jazzband/django-auditlog/pull/496))~~
- fix: Always set remote_addr even if the request has no authenticated user. ([#484](https://github.com/jazzband/django-auditlog/pull/484))
- fix: Fix a bug in getting field's `verbose_name` when model is not accessible. ([508](https://github.com/jazzband/django-auditlog/pull/508))
- fix: Fix a bug in `serialized_data` with F expressions. ([508](https://github.com/jazzband/django-auditlog/pull/508))

## 2.2.2 (2023-01-16)

No changes.

## 2.2.1 (2022-11-28)

#### Fixes

- fix: Make log entries read-only in the admin. ([#449](https://github.com/jazzband/django-auditlog/pull/449))
- fix: Handle IPv6 addresses in `X-Forwarded-For`. ([#457](https://github.com/jazzband/django-auditlog/pull/457))

## 2.2.0 (2022-10-07)

#### Improvements
- feat: Add `ACCESS` action to `LogEntry` model and allow object access to be logged. ([#436](https://github.com/jazzband/django-auditlog/pull/436))
- feat: Add `serialized_data` field on `LogEntry` model. ([#412](https://github.com/jazzband/django-auditlog/pull/412))
- feat: Display the field name as it would be displayed in Django Admin or use `mapping_field` if available [#428](https://github.com/jazzband/django-auditlog/pull/428)
- feat: New context manager `disable_auditlog` to turn off logging and a new setting `AUDITLOG_DISABLE_ON_RAW_SAVE`
to disable it during raw-save operations like loaddata. [#446](https://github.com/jazzband/django-auditlog/pull/446)
- Python: Confirm Python 3.11 support ([#447](https://github.com/jazzband/django-auditlog/pull/447))
- feat: Replace the `django.utils.timezone.utc` by `datetime.timezone.utc`. [#448](https://github.com/jazzband/django-auditlog/pull/448)

#### Fixes

- fix: Display `created` timestamp in server timezone ([#404](https://github.com/jazzband/django-auditlog/pull/404))
- fix: Handle port in `remote_addr` ([#417](https://github.com/jazzband/django-auditlog/pull/417))
- fix: Handle the error with AttributeError: 'OneToOneRel' error occur during a `PolymorphicModel` has relation with other models ([#429](https://github.com/jazzband/django-auditlog/pull/429))
- fix: Support search by custom USERNAME_FIELD ([#432](https://github.com/jazzband/django-auditlog/pull/432))

## 2.1.1 (2022-07-27)

#### Improvements

- feat: Display the diff for deleted objects in the admin ([#396](https://github.com/jazzband/django-auditlog/pull/396))
- Django: Confirm Django 4.1 support ([#406](https://github.com/jazzband/django-auditlog/pull/406))

#### Fixes

- fix: Pin `python-dateutil` to 2.7.0 or higher for compatibility with Python 3.10 ([#401](https://github.com/jazzband/django-auditlog/pull/401))

## 2.1.0 (2022-06-27)

#### Improvements
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ django-auditlog

[![Jazzband](https://jazzband.co/static/img/badge.svg)](https://jazzband.co/)
[![Build Status](https://github.com/jazzband/django-auditlog/workflows/Test/badge.svg)](https://github.com/jazzband/django-auditlog/actions)
[![Docs](https://readthedocs.org/projects/django-auditlog/badge/?version=latest)](http://django-auditlog.readthedocs.org/en/latest/?badge=latest)
[![Docs](https://readthedocs.org/projects/django-auditlog/badge/?version=latest)](https://django-auditlog.readthedocs.org/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/jazzband/django-auditlog/branch/master/graph/badge.svg)](https://codecov.io/gh/jazzband/django-auditlog)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/django-auditlog.svg)](https://pypi.python.org/pypi/django-auditlog)
[![Supported Django versions](https://img.shields.io/pypi/djversions/django-auditlog.svg)](https://pypi.python.org/pypi/django-auditlog)

**Migrate to V3**

Check the [Upgrading to version 3](https://django-auditlog.readthedocs.io/en/latest/upgrade.html) doc before upgrading to V3.

```django-auditlog``` (Auditlog) is a reusable app for Django that makes logging object changes a breeze. Auditlog tries to use as much as Python and Django's built in functionality to keep the list of dependencies as short as possible. Also, Auditlog aims to be fast and simple to use.

Auditlog is created out of the need for a simple Django app that logs changes to models along with the user who made the changes (later referred to as actor). Existing solutions seemed to offer a type of version control, which was found excessive and expensive in terms of database storage and performance.
Expand All @@ -32,8 +36,10 @@ If you have great ideas for Auditlog, or if you like to improve something, feel
Releases
--------

1. Make sure all tests on `master` are green.
2. Create a new branch `vX.Y.Z` from master for that specific release.
3. Bump versions in `setup.py` and `docs/source/conf.py` (docs have 2 places where the versions need to be changed!)
4. Pull request `vX.Y.Z` -> `master`.
5. Pull request `master` -> `stable`. This merge triggers the deploy to pypi.
1. Make sure all tests on `master` are green
2. Create a new branch `vX.Y.Z` from master for that specific release
3. Update the CHANGELOG release date
4. Pull request `vX.Y.Z` -> `master`
5. As a project lead, once the PR is merged, create and push a tag `vX.Y.Z`: this will trigger the release build and a notification will be sent from Jazzband of the availability of two packages (tgz and wheel)
6. Test the install
7. Publish the release to PyPI
8 changes: 2 additions & 6 deletions auditlog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import version

try:
__version__ = get_distribution("django-auditlog").version
except DistributionNotFound:
# package is not installed
pass
__version__ = version("django-auditlog")
37 changes: 30 additions & 7 deletions auditlog/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from functools import cached_property

from django.conf import settings
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.core.paginator import Paginator
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _

from auditlog.count import limit_query_time
from auditlog.filters import (
CIDFilter,
FieldFilter,
ResourceTypeFilter,
ShortActorFilter,
Expand All @@ -26,27 +29,36 @@ def count(self):
return super().count


@admin.register(LogEntry)
class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
list_display = ["created", "resource_url", "action", "msg_short", "user_url"]
list_display = [
"created",
"resource_url",
"action",
"msg_short",
"user_url",
"cid_url",
]
search_fields = [
"timestamp",
"object_repr",
"changes",
"actor__first_name",
"actor__last_name",
"actor__{}".format(get_user_model().USERNAME_FIELD),
f"actor__{get_user_model().USERNAME_FIELD}",
]
list_filter = [
"action",
ShortActorFilter,
ResourceTypeFilter,
FieldFilter,
("timestamp", get_timestamp_filter()),
CIDFilter,
]
readonly_fields = ["created", "resource_url", "action", "user_url", "msg"]
fieldsets = [
(None, {"fields": ["created", "user_url", "resource_url"]}),
("Changes", {"fields": ["action", "msg"]}),
(None, {"fields": ["created", "user_url", "resource_url", "cid"]}),
(_("Changes"), {"fields": ["action", "msg"]}),
]
list_select_related = ["actor", "content_type"]
show_full_result_count = False
Expand All @@ -58,8 +70,19 @@ def has_add_permission(self, request):
def has_change_permission(self, request, obj=None):
return False

@cached_property
def _own_url_names(self):
return [pattern.name for pattern in self.urls if pattern.name]

def has_delete_permission(self, request, obj=None):
if (
request.resolver_match
and request.resolver_match.url_name not in self._own_url_names
):
# only allow cascade delete to satisfy delete_related flag
return super().has_delete_permission(request, obj)
return False


admin.site.register(LogEntry, LogEntryAdmin)
def get_queryset(self, request):
self.request = request
return super().get_queryset(request=request)
Loading