Django Signals | Pre and Post Delete
HTML-код
- Опубликовано: 30 ноя 2024
- In this tutorial we configure an application to capture signals from the Django signal dispatcher when performing delete() actions. If you are new to Django signals this tutorials starts to help you understand how to capture Django signals to perform additional tasks in your application.
Code Repository:
github.com/ver...
The best brief explanation! Great video
Love you sir nice videos I am understanding all videos of you
Glad to hear that
Great video as usual. One of the problems related to signals is that it messes up working with bulk operations, imagine running a pre save signal on a 1000 records update. We would switch from 1 single bulk save to 1000 individual saves.
Much like every tutorial, this is the reality / experience that you can only gage from actually working in industry. Thank you for sharing.
Great video. I have been exploring signals and this is very helpful. I was wondering if you might be able to extend this or show and example of deleting a profile picture from the file system when someone updates their picture to a new one. The url path to the image is stored in the db but the file is in the upload directory. That gets really full as new profiles are uploaded or changed. A working example would be amazing
Hi Brant. A great tutorial idea, thank you. Please just let me know if this should be a API call or if you would prefer a Django template example.
On reflection, im wondering if signals would be the approach here. You would probably want to take the approach of overriding the save() method.
@@veryacademy I prefer the template example. It is applicable to a project I am working on right now. I built a custom upload to store all the images from one user to their own directories. ie. media/uploads/user1/img1.png
media/uploads/user1/new-img.png
media/uploads/user2/profile.png
etc.
My thought was I just delete the user folder with a signal when I deleted the user. But even before then the user folder could get pretty full with profile image changes. (I do use Pillow to resize the upload by re-writing save method but just lots of content to manage in a large system)
@@veryacademy just seeing this second reply. You could be correct as that was something I was investigating as well. I am still somewhat new to Django so which ever solution you think would be best would make a great video 😁
Thanks Very;
would you please provide a video that make real world changes.
For example:
If we have a real time data website changes every one minute, the data should change in our Django app.
Thank you in advance.
Hey, no problem. Let me know what tech stack you would like this example to use - Django templates or API approach with React etc
@@veryacademy
it's an idea came to my mind when i was using Django and python.
The idea is consuming API from a website that using currency prices and the prices are changing every specific time, and using Django and celery and signals i think. we consume from that site and put them in our database and display them in our Django site.
i'm suggesting this because i want to be comfortable with signals and celery.
Thank you so much Very for your time
How can we understand the user who started this process? example: is_superuser or not ?
Hey! I'm facing an issue and am hoping you might know the solution.
I need to create a double nested inline form, but have no idea how to go about this (Outside of django admin, so I cannot use the nested_inlines module). Any help? :)
👍
Thank you