if not LogEntry._meta.installed:
    raise ImproperlyConfigured(
        "You'll need to put 'django.contrib.admin' in your INSTALLED_APPS setting before you can use the admin application."
        )

def log_action(user_id, content_type_id, object_id, object_repr,
    action_flag, change_message=''):
    log_count = LogEntry.objects.count()
if log_count > LOG_THRESHOLD:
    to_delete = LogEntry.objects.all()[LOG_SIZE:log_count]
for d in to_delete:
    d.delete()
LogEntry.objects.log_action(user_id, content_type_id, object_id,
    object_repr, action_flag, change_message)
Регистрация активности администратора Django — Django