Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fugimuse opened this issue Nov 1, 2023 · 2 comments

Comments

@fugimuse
Copy link

fugimuse commented Nov 1, 2023

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)
@fugimuse
Copy link
Author

fugimuse commented Nov 1, 2023

If this seems like a good idea, I would be interested in taking it on and submitting a pull request.

@hramezani
Copy link
Member

Thanks @fugimuse for bringing this.
Yeah, seems a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants