djangodjango-rest-frameworkdjango-auditlog

django-auditlog not working for User model


I am using django-auditlog for creating entries in LogEntry table. my actions for User Model are not getting logged in LogEntry table.

my User model -

class User(AbstractUser):
...
...
...

username = None

USERNAME_FIELD = 'id'
REQUIRED_FIELDS = []

objects = UserManager()

def __str__(self):
  return f"{self.email}"

...
...

auditlog.register(User)

*I have to use django-auditlog only so pls suggest accordigly

TIA


Solution

  • I use django-auditlog version 2.1.1. In my case, I've solved it this way:

    AUDITLOG_INCLUDE_TRACKING_MODELS = (
        {
            "model": "auth.User",
            "exclude_fields": ["last_login"],
        },
    )
    

    I hope that it was useful!