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...

Комментарии • 17

  • @slimecraft3
    @slimecraft3 Год назад +2

    The best brief explanation! Great video

  • @prasanthgandhudi3617
    @prasanthgandhudi3617 Год назад +1

    Love you sir nice videos I am understanding all videos of you

  • @fedepia84
    @fedepia84 2 года назад +1

    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.

    • @veryacademy
      @veryacademy  2 года назад +1

      Much like every tutorial, this is the reality / experience that you can only gage from actually working in industry. Thank you for sharing.

  • @BrantScalan
    @BrantScalan 2 года назад +1

    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

    • @veryacademy
      @veryacademy  2 года назад

      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.

    • @veryacademy
      @veryacademy  2 года назад

      On reflection, im wondering if signals would be the approach here. You would probably want to take the approach of overriding the save() method.

    • @BrantScalan
      @BrantScalan 2 года назад

      @@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)

    • @BrantScalan
      @BrantScalan 2 года назад

      @@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 😁

  • @TechWithSabri
    @TechWithSabri 2 года назад +1

    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.

    • @veryacademy
      @veryacademy  2 года назад

      Hey, no problem. Let me know what tech stack you would like this example to use - Django templates or API approach with React etc

    • @TechWithSabri
      @TechWithSabri 2 года назад

      @@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

  • @caglargulucan
    @caglargulucan 2 года назад

    How can we understand the user who started this process? example: is_superuser or not ?

  • @n.i.g.e.l
    @n.i.g.e.l 2 года назад

    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? :)

  • @ibrahimoglu
    @ibrahimoglu 2 года назад +1

    👍