Skip to content

Instantly share code, notes, and snippets.

@victory-sokolov
Created April 1, 2023 16:48
Show Gist options
  • Save victory-sokolov/5485f0bbb7f58da5ad5a8bec3ee4b18a to your computer and use it in GitHub Desktop.
Save victory-sokolov/5485f0bbb7f58da5ad5a8bec3ee4b18a to your computer and use it in GitHub Desktop.
Django admin
# Add Logging to specific data
from django.contrib.admin.models import CHANGE, LogEntry
from django.contrib.contenttypes.models import ContentType
LogEntry.objects.log_action(
user_id=request.user.id,
content_type_id=ContentType.objects.get_for_model(self.model).pk,
object_id=object_id,
object_repr=object_id,
change_message=message,
action_flag=CHANGE,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment