Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.db import models
5# Exports
7__all__ = (
8 "AuditMixin",
9)
11# Mixins
14class AuditMixin(models.Model):
15 """Base for other abstract auditing models.
17 The class serves two purposes:
19 1. Provide a centralized ``audit()`` method that child classes may call to save audit data.
20 2. Act as a flag for the ``is_audit_model()`` function to indicate the presence of audit functionality.
22 """
24 class Meta:
25 abstract = True
27 def audit(self, user, commit=True):
28 """Save the model along with audit data.
30 :param user: The user saving the record.
31 :type user: AUTH_USER_MODEL
33 :param commit: Whether to save immediately.
34 :type commit: bool
36 """
37 if commit:
38 self.save()