delete history django simple
# Import necessary modules
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
# Define a function to delete the history for a specific object
def delete_object_history(obj):
content_type = ContentType.objects.get_for_model(obj)
LogEntry.objects.filter(content_type=content_type, object_id=obj.id).delete()
# Example usage: Assuming you have a model instance called 'my_instance'
delete_object_history(my_instance)