I’ve started using django-auditlog in my project. I was able to successfully log entries for changes to my model, however I want to make a tweak on how audit log displays change list in django admin. The problem is I’ve a ForeignKey
in my Task
model, it does have a __str__
method defined. When I make change to stage
field on my Task
model, the entry is logged, but it shows the stage id
instead of stage.name
as per defined in __str__
(i believe this is how it’s supposed to work.
Here is my models.py
class Stage(models.Model):
name = models.CharField(max_length=64)
def __str__(self):
return self.name
class Task(models.Model):
name = models.CharField(max_length=64)
stage = models.ForeignKey(Stage, on_delete=models.SET_NULL, null=True)
## other unrelated fields...
def __str__(self):
return self.name
Here is how the Log Entry
is displayed currently:
Here is the expected result:
I’ve read the documentation of django-auditlog but couldn’t found any help. Any suggestion?