Creating a log for any changes in any model data i.e creation, updation and deletion??

22 views
Skip to first unread message

Abhishek Tiwari

unread,
Jun 23, 2019, 2:40:38 PM6/23/19
to Django users

Hey everybody.. So i have been given a task to create a Activity Log page which shows the changes that have happened to any model data i.e either it is created or updated or deleted.

My solution is to create a Activity model and store the changes following way-

1- override the save method and delete method and then save in Activity model or

2- use signals and then save it the Activity model.

the Activity model right now contains only these fields-

performed_on,

performed_by,

type_of_operation- Creation, Updation, Deletion

Is there any other better way to achieve this??

Brandon Rosenbloom

unread,
Jun 24, 2019, 2:38:06 PM6/24/19
to Django users
I did this using Django signals. Here’s the documentation:
https://docs.djangoproject.com/en/2.2/topics/signals/

Brandon Rosenbloom

unread,
Jun 24, 2019, 2:38:06 PM6/24/19
to Django users

Abhishek Tiwari

unread,
Jun 24, 2019, 3:53:43 PM6/24/19
to Django users
That is the approach i have in mind.. Thank you..

Jani Tiainen

unread,
Jun 24, 2019, 9:37:00 PM6/24/19
to django...@googlegroups.com
Hi.

Note that there are still ways to modify data withouth signals getting fired. Nor save or delete is called.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e286a8ea-b2d6-45ed-a7fa-f4a0f5478274%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages