How to monitor content updates or deletion in Django web applications

78 views
Skip to first unread message

Ram

unread,
Oct 4, 2023, 3:44:04 AM10/4/23
to django...@googlegroups.com
Hi,

We would like to add this feature in our Web application and capture the following events in log files:

1. If any image is deleted by any reason
2. Any content is deleted by any reason

Does Django have any libraries or functions to achieve this?

Best regards,
~Ram


David Nugent

unread,
Oct 4, 2023, 3:59:00 AM10/4/23
to django...@googlegroups.com, Ram
The may not be enough context in your question but I imagine that the following link may take you to something that may work for you.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BOi5F3GDxbL_3C20ygwE9yumUdLxDgZJRdLEuM9Wdm%2BeTyfEA%40mail.gmail.com.

Ruby

unread,
Oct 4, 2023, 7:45:29 AM10/4/23
to django...@googlegroups.com
Hi there,
I don't know if there's a library for that, but I believe you can build what you need using the built-in Django Content-Type 
I have used it a few times and Django admin site also uses it under the hood.

David Nugent

unread,
Oct 4, 2023, 9:04:19 AM10/4/23
to django...@googlegroups.com, Ruby
Yes, certainly worth mentioning. ContentTypes is the secret sauce in django admin for sure and extremely useful for building generic functionality without hard coding to specific models. It’s like a through table in a relational db, where entities can be tracked. And it’s all automatic, built into every django app.

Timothy Myers

unread,
Oct 4, 2023, 5:44:37 PM10/4/23
to Django users
I am also not sure of the scope of your question.  If you're asking about a
file deleted from the system by a method other than Django.  I use a trusted database
of files required with a hash and have a process (Django script) that runs and checks
both the presence of a file and its hash code.   
This notifies me of not only deletions but also changes to core items that I want to monitor by any 
method outside my control updates that maintain the trusted database and log dates who made the change.   
This also helped me monitor for duplicate pictures and files so that if someone loads a second copy of the 
same picture for a different page even with a different name it is noted by the hashcode.  So if one image is being
updated other pages can be reviewed as well to see if they should be updated at the same time.  Do we need both 
or should we change both images and update both pages? 
There is also a file with pages and keys to external use static items on a page.  Many are done systematically with
code and databases this picture, this text, and this format so the programmed changes also maintain much of the database 
updates.  The more pages added the more complex the maintenance without the help from the system as pages are 
added and deleted or updated.
This ensures that an image is not removed if removing a page and it is not the only user of the image.  This
helps prevent broken links or you can scan logs for 404 but then a user gets the message instead of prevention.


The signals are great for triggering events done through Django code and database actions.  But I don't think
it can detect that an image was substituted or deleted outside of its code base but OS commands or rouge programs.
It would be much harder to both change the file and update the hashcode.  Using signals and a trusted db might 
give you the best of both worlds
Reply all
Reply to author
Forward
0 new messages