diff --git a/CHANGELOG.md b/CHANGELOG.md index b84bfc7..ca6a872 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - 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) diff --git a/auditlog/admin.py b/auditlog/admin.py index 2d79675..ee868e2 100644 --- a/auditlog/admin.py +++ b/auditlog/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.contrib.auth import get_user_model from auditlog.filters import ResourceTypeFilter from auditlog.mixins import LogEntryAdminMixin @@ -14,7 +15,7 @@ class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin): "changes", "actor__first_name", "actor__last_name", - "actor__username", + f"actor__{get_user_model().USERNAME_FIELD}", ] list_filter = ["action", ResourceTypeFilter] readonly_fields = ["created", "resource_url", "action", "user_url", "msg"]