Support search by custom USERNAME_FIELD (#432)

This commit is contained in:
Alieh Rymašeŭski 2022-09-21 14:19:49 +00:00 committed by GitHub
parent a56d0e6f78
commit 0f57525058
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -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)

View file

@ -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"]