2025-11-19 08:46:43 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2023-07-13 21:56:08 +00:00
|
|
|
from importlib.metadata import version
|
2022-11-21 15:50:34 +00:00
|
|
|
|
2025-11-19 08:46:43 +00:00
|
|
|
from django.apps import apps as django_apps
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
|
2023-07-13 21:56:08 +00:00
|
|
|
__version__ = version("django-auditlog")
|
2025-11-19 08:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_logentry_model():
|
|
|
|
|
try:
|
|
|
|
|
return django_apps.get_model(
|
|
|
|
|
settings.AUDITLOG_LOGENTRY_MODEL, require_ready=False
|
|
|
|
|
)
|
|
|
|
|
except ValueError:
|
|
|
|
|
raise ImproperlyConfigured(
|
|
|
|
|
"AUDITLOG_LOGENTRY_MODEL must be of the form 'app_label.model_name'"
|
|
|
|
|
)
|
|
|
|
|
except LookupError:
|
|
|
|
|
raise ImproperlyConfigured(
|
|
|
|
|
"AUDITLOG_LOGENTRY_MODEL refers to model '%s' that has not been installed"
|
|
|
|
|
% settings.AUDITLOG_LOGENTRY_MODEL
|
|
|
|
|
)
|