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 · 8 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.

@CleitonDeLima
Copy link
Contributor

CleitonDeLima commented Oct 1, 2024

@fugimuse
Is this in progress? I can make the change if no one has started yet.

@hramezani
Copy link
Member

@CleitonDeLima feel free to work on this

@CleitonDeLima
Copy link
Contributor

CleitonDeLima commented Oct 7, 2024

A slightly off-topic question: @hramezani how should I configure my environment correctly for this project? I configured venv, pip install -e . and pip install django, run the tests with runtests.py/tox.
Is there anything else I need to configure? Sometimes I miss not having a manage.py to create migrations, por example.

@hramezani
Copy link
Member

A slightly off-topic question: @hramezani how should I configure my environment correctly for this project? I configured venv, pip install -e . and pip install django, run the tests with runtests.py/tox. Is there anything else I need to configure? Sometimes I miss not having a manage.py to create migrations, por example.

I also use the same setup. not sure what the problem is.

@CleitonDeLima
Copy link
Contributor

I also use the same setup. not sure what the problem is.

I created this draft, but I can't run the tests with a new CustomLogEntryModel.

Maybe I configured the tests incorrectly.

@hramezani
Copy link
Member

I also use the same setup. not sure what the problem is.

I created this draft, but I can't run the tests with a new CustomLogEntryModel.

Maybe I configured the tests incorrectly.

Thanks @CleitonDeLima for the PR and sorry for late reply!
Unfortunatelly I am busy these days and can't help you a a lot to fix the problem.

Have you checked the CI error django.db.utils.ProgrammingError: relation "django_content_type" does not exist?

you probably should be able to run the test easily by tox e.g. tox -e py310-django50

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

3 participants