Custom return classes does not display objects in logentry table
See original GitHub issueI am having a problem with the audit log for classes that have a customised return. For example I have this code:
class Adress(models.Model):
type_id= models.ForeignKey(AddressType)
street = models.CharField(max_length=256, null=True)
number = models.CharField(max_length=16, null=True)
zip_code= models.CharField(max_length=16, null=True)
city = models.CharField(max_length=64, null=True)
country = models.CharField(max_length=64, null=True)
def __str__(self):
return self.city
auditlog.register(Adress)
My database records everything nicely, however, the object that changed is not logged because I have a custom return.
See printscreen example subnets and networks:

If I remove the returns I get the object notation properly. But I have a lot of forms where the foreign key needs to be displayed the return I give it, for example “city” for class address. But if I change something with that class, it only returns the city in the table where I would like to see “Address Object”.
Hope you can help me out!
Best, Dylienne
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Django - Custom Admin Actions Logging - Stack Overflow
Show activity on this post. All changes you do in Django Admin is logged in the table django_admin_table and you can also see...
Read more >The Django admin site
Do you need a ModelAdmin object at all? In the preceding example, the ModelAdmin class doesn't define any custom values (yet). As a...
Read more >Error Processing | Using ObjectScript | InterSystems IRIS Data ...
Describes the three types of InterSystems ObjectScript error handling: TRY and CATCH blocks, the %Status return code, and $ZTRAP error trapping.
Read more >Console log formatting - .NET - Microsoft Learn
Learn how to use available console log formatting, or implement custom log formatting for your .NET applications.
Read more >Adding Logging in Angular Applications - CODE Magazine
The date/time is not that important when just logging to the console ... The LogEntry class, shown in Listing 4, has properties for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello Audiolion,
I understand, thank you.
However, the returns are very much alike as all are ipv4 addresses. I would like to make a distinction between subnets, networks, ip’s, pub.ip’s etc. In the logentry column, they all return ipv4 notations where it then is not to be distinguished at what object the object_repr belongs to.
Your solution is okay for this project. Thank you.
Best,
You can write your own
get_additional_data
method to return additional information about the object in a json format that will be tracked by auditloghttps://github.com/jjkester/django-auditlog/blob/v0.4.3/src/auditlog_tests/models.py#L87
then you can access it on the log_entry object through the
additional_data
propertyhttps://github.com/jjkester/django-auditlog/blob/v0.4.3/src/auditlog_tests/tests.py#L219
The code that runs it is https://github.com/jjkester/django-auditlog/blob/master/src/auditlog/models.py#L44
basically check if the model being saved has a callable
get_addtional_data
and if so add the result to anadditional_data
property on the log entry