mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-17 20:11:06 +00:00
Merge 7bf1798e55 into 938e644177
This commit is contained in:
commit
d0acaa1f8f
1 changed files with 16 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ from django.db.models import Q, QuerySet
|
|||
from django.utils import formats
|
||||
from django.utils import timezone as django_timezone
|
||||
from django.utils.encoding import smart_str
|
||||
from django.utils.text import Truncator
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from auditlog.diff import mask_str
|
||||
|
|
@ -488,6 +489,19 @@ class LogEntry(models.Model):
|
|||
except AttributeError:
|
||||
# if the field is a relationship it has no internal type and exclude it
|
||||
continue
|
||||
|
||||
if field_type == "ManyToManyField":
|
||||
values_display = values
|
||||
values_display["objects"] = [
|
||||
f"{Truncator(i).chars(140,html=True)}..." if len(i) > 140 else i
|
||||
for i in values["objects"]
|
||||
]
|
||||
verbose_name = model_fields["mapping_fields"].get(
|
||||
field.name, getattr(field, "verbose_name", field.name)
|
||||
)
|
||||
changes_display_dict[verbose_name] = values_display
|
||||
continue
|
||||
|
||||
for value in values:
|
||||
# handle case where field is a datetime, date, or time type
|
||||
if field_type in ["DateTimeField", "DateField", "TimeField"]:
|
||||
|
|
@ -508,7 +522,8 @@ class LogEntry(models.Model):
|
|||
|
||||
# check if length is longer than 140 and truncate with ellipsis
|
||||
if len(value) > 140:
|
||||
value = f"{value[:140]}..."
|
||||
# value = f"{value[:140]}..."
|
||||
value = f"{Truncator(value).chars(140,html=True)}..."
|
||||
|
||||
values_display.append(value)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue