Generic relationship between model Logentry

Asked

Viewed 28 times

0

Someone has worked with Auditlog on Django ? Documentation of Django Auditlog

Let’s say I have this model:

class Cadastro(models.Model):
    nome = models..TextField()

auditlog.register(Cadastro)

I would like a queryset that returns all the records of the Registration table along with the attributes of the auditlog. For my researches, I could create a generic Foreignkey attribute in the model Register to link with the Logs table, but I still could not find a solution.

I appreciate any help.

  • Rodolfo, what is Auditlog? It’s a package (like that or that)? Is the Logentry do Django Admin? It would be nice if you [Edit] your question and clarify these points (preferably using the tag of the module you are using)

  • @fernandosavio is second link you posted, add a link to make it clear. Thanks for the feedback.

1 answer

0


I managed to solve by doing the following:

from auditlog.models import LogEntry
from auditlog.registry import auditlog
from django.contrib.contenttypes.fields import GenericRelation

class Cadastro(models.Model):
nome = models..TextField()
log = GenericRelation(LogEntry)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.