Skip to content

Add AbstractLogEntry class to allow extension without creating additional table #580

@fugimuse

Description

@fugimuse

I would like to be able to extend LogEntry with custom fields without introducing an additional table. I think this can be be accomplished by introducing a new class AbstractBaseLogEntry, containing all of the code from LogEntry and adding:

class AbstractBaseLogEntry
    class Meta:
        abstract = True

    # Existing code from LogEntry

class LogEntry(AbstractBaseLogEntry):
    pass

New fields could then be accommodated in the log as follows:

# In myapp.models

from auditlog.models import AbstractBaseLogEntry

class CustomLogEntry(AbstractBaseLogEntry):
    new_field1 = models.CharField(max_length=255, blank=True, null=True)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions