Django Media Files - Handling User Uploads in Django Forms & Models

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

ความคิดเห็น • 80

  • @juniorsemerzier660
    @juniorsemerzier660 ปีที่แล้ว +5

    great content ! Now we waiting for how to use static files in production.

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thanks. Will look into that one in a future topic!

  • @perpy7149
    @perpy7149 หลายเดือนก่อน +1

    i dont know English but i can undrestand what you do, thats perfect course , thank you l

    • @bugbytes3923
      @bugbytes3923  29 วันที่ผ่านมา

      Thank you - I'm glad to hear that!

  • @mikedodds9926
    @mikedodds9926 7 หลายเดือนก่อน

    great stuff , as always nice and clear , really understandable , these videos are always my go to... thank you

    • @bugbytes3923
      @bugbytes3923  7 หลายเดือนก่อน

      Thanks a lot!

  • @padelmaniac
    @padelmaniac ปีที่แล้ว +1

    All of your content is amazing

  • @atoprak00
    @atoprak00 ปีที่แล้ว +2

    I did use Django clean up module before but learning simply rewriting delete method was good, nice as always and thanks. Next video will be interesting 👍

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thanks for watching! Lots of different techniques in Django!

  • @valentino7057
    @valentino7057 ปีที่แล้ว +1

    so excited for the next video!

  • @djtoon8412
    @djtoon8412 ปีที่แล้ว +1

    nice one you are really inspiring me in the world of django

  • @raffritter6766
    @raffritter6766 ปีที่แล้ว +1

    Can't wait for the next video : )

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thanks a lot for watching!

  • @hardikkalaria159
    @hardikkalaria159 ปีที่แล้ว +1

    Can't wait for the next one!

  • @adityanjsg99
    @adityanjsg99 หลายเดือนก่อน

    Helped me once again... Thank you stallone :)

    • @bugbytes3923
      @bugbytes3923  หลายเดือนก่อน

      Awesome haha - thanks!

  • @bartoszjanprzybyszewski1891
    @bartoszjanprzybyszewski1891 11 หลายเดือนก่อน +3

    the dog indeed is amazing

  • @claytonbennett7797
    @claytonbennett7797 3 หลายเดือนก่อน

    Thanks. I am a Python user, trying to deploy my python project as a web app. Integrating Django with a react frontend has been a new step for me, when it comes to integrating something like dropzonejs. It's nice that your way shows just Django.

  • @seydinaoumarsamabaly1806
    @seydinaoumarsamabaly1806 ปีที่แล้ว +1

    Very interesting tutorial thank you !

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thank you, thanks for watching!

  • @thibaultledanois455
    @thibaultledanois455 ปีที่แล้ว

    Perfect tuto for me ! Thank you so much :)

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      You're welcome - thanks for watching! :)

  • @stevemulcahy5014
    @stevemulcahy5014 5 หลายเดือนก่อน

    What would be a good way to add multiple images to a dog, but not always either needing to add images or to have a limit, like for a gallery for that instance? Would it be making a model called images that has a foreign key to the dog? Then could you have the form for those images on the same creation form as the dog?

  • @SkeechFab
    @SkeechFab ปีที่แล้ว +1

    This is so clearly presented 🙏Could you explain how to automatically reduce file size uploaded images?

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thank you very much! I can look into that one, along with resizing, in a future video!

  • @dodokwak
    @dodokwak ปีที่แล้ว +2

    Great video. Thx. Looking forward to the next. Tried to upload images on S3 (via django -storages) , it works well but I can't delete an uploaded image from the bucket when the "user" wants to delete only the image(partial delete) but not the object (post) entirely.

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thank you!
      Interesting problem, I'll see if I can address that in a future video.

  • @Septumsempra8818
    @Septumsempra8818 ปีที่แล้ว

    How do we save the images to a cdn? Eg I want users to upload a profile picture, how do they upload it and it gets converted to an image url on cloudinary?

  • @mehdismaeili3743
    @mehdismaeili3743 10 หลายเดือนก่อน +1

    Excellent.

  • @streamocu2929
    @streamocu2929 9 หลายเดือนก่อน +1

    you are django hero

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks a lot 😂

  • @tomekklewicki9221
    @tomekklewicki9221 ปีที่แล้ว +1

    So cool!

  • @TomislavMiletic
    @TomislavMiletic ปีที่แล้ว

    Thank you! Okay so i have an image field model with a default value "default=default-images/category.jpg" so that each new category can have something set if a user doesn't upload an image rightaway.
    But the problem occures when i test and delete the category. Now that default image gets deleted, so each new category that is created without an image, now has that empty value.
    Is there a workaround, but without doing it conditionally in the template?

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว +1

      If I understand correctly - On the backend, you can prevent the deletion of the default image within the model's delete() function.
      In that function, check if the model that you're deleting has the image-field's filename set to that default image, and avoid deleting the file if so (you can still remove the category itself, of course). Otherwise, if NOT the default, you can then delete that file, as well as the model.

    • @TomislavMiletic
      @TomislavMiletic ปีที่แล้ว

      @@bugbytes3923 Thank you, i will try that :)

  • @zakchips
    @zakchips ปีที่แล้ว +1

    Could you please give us some adivise concerning resizing of the uploaded images?
    I try to do it on the client side (js) but I'm not sure if it's the best option.
    I do want to check the user's data on my server side for the sake of validation. To resize the uploaded image in the view or in the save method of the model has a risk to create a bottleneck. May be to resize it with lambda function on aws? Thank you in advance.

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว +1

      Different ways to do this, you can resize in Django and save to your media storage (perhaps best done in a Celery task, or some asynchronous method). An AWS lambda function would work well if your resources are stored on S3.

    • @zakchips
      @zakchips ปีที่แล้ว

      @@bugbytes3923 Thank you. Would it be a problem in an inability to accept images as an argument in celery function. In a view, if form is valid I can bind uploaded file to a model instance, and save it applying resize process in the save method. But it's not the case in celery.
      Could you make a lesson about it in the feature, please.

  • @DjangoPractice
    @DjangoPractice ปีที่แล้ว +1

    super ❤❤❤❤❤❤ Thank You

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Thanks a lot for watching!

  • @yurigorohov9575
    @yurigorohov9575 ปีที่แล้ว

    Hello, How can i change text lang for the fileinput?

  • @ayotundeakinwumi8847
    @ayotundeakinwumi8847 7 หลายเดือนก่อน

    It upload image to folder but not saving to mysql database. pls kindly asist

  • @anthonychianain2241
    @anthonychianain2241 ปีที่แล้ว +1

    Thanks so much

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      You’re welcome, thanks for the view!

  • @DevendraSingh-ow2xp
    @DevendraSingh-ow2xp 6 หลายเดือนก่อน

    Image upload field works in django admin but not working in template (I am not using django forms)

  • @vivaldi-qo7xj
    @vivaldi-qo7xj ปีที่แล้ว +1

    Thnx.

  • @JustinSpryce
    @JustinSpryce ปีที่แล้ว +1

    Greate Lesson

  • @aafan.kuware
    @aafan.kuware 7 หลายเดือนก่อน

    17:42 can you make a dedicated video on how to serve static and media file in production using nginx server, also setting up a contabo object storage instead of aws as contabo is cheap and there's no videos on that.

  • @ali-cu1ne
    @ali-cu1ne 7 หลายเดือนก่อน

    Ammmmmazing content ❤

    • @bugbytes3923
      @bugbytes3923  7 หลายเดือนก่อน

      Thanks so much!

  • @allyouinfotech7936
    @allyouinfotech7936 ปีที่แล้ว

    i want to store large video files how i link cloud storage with django models

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Use a FileField with django-storages to link the video to its cloud location.

  • @frameff9073
    @frameff9073 ปีที่แล้ว +1

    Thank you

  • @satwikawasthi2002
    @satwikawasthi2002 23 วันที่ผ่านมา

    Where is front end part for submitting image?

  • @JustForFun1426-t4k
    @JustForFun1426-t4k 9 หลายเดือนก่อน

    Good work.
    Please show us how to host a website in bluehosy

  • @gibbytravis
    @gibbytravis 8 หลายเดือนก่อน

    You showed me what not to do in production, but you didn't tell me what I should do in production. How do I server files in a production environment?

  • @alimansimov1929
    @alimansimov1929 7 หลายเดือนก่อน

    How to serve in production environment?

  • @adamfatyga7977
    @adamfatyga7977 ปีที่แล้ว

    I dont know why, when i want to runserver at 6:40 i have error: from forms import DogForm
    ModuleNotFoundError: No module named 'forms'

    • @bugbytes3923
      @bugbytes3923  ปีที่แล้ว

      Try: from .forms import DogForm
      Note the dot in from of forms: .forms
      To tell django the forms module is in the current app

    • @adamfatyga7977
      @adamfatyga7977 ปีที่แล้ว +1

      @@bugbytes3923 I just realized it at the same time :)
      But thanks a lot for your quick reply.

  • @ashishbhopte8149
    @ashishbhopte8149 7 หลายเดือนก่อน

    Thanks

  • @aafan.kuware
    @aafan.kuware 7 หลายเดือนก่อน

    28:45 yes, please make it.

  • @YT4ntertainment
    @YT4ntertainment 8 หลายเดือนก่อน

    Good Shit.

    • @bugbytes3923
      @bugbytes3923  8 หลายเดือนก่อน

      Cheers!!

    • @YT4ntertainment
      @YT4ntertainment 8 หลายเดือนก่อน

      Can you do a video on ORM relations@@bugbytes3923

  • @JustForFun1426-t4k
    @JustForFun1426-t4k 9 หลายเดือนก่อน

    Thank y

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks for watching!

  • @toddgilbey3979
    @toddgilbey3979 6 หลายเดือนก่อน

    I am absolutely seething right now, Why do I just keep getting the "Could not find config for 'default' in settings.STORAGES."
    Absolutely stupid situation.

  • @victordavila3642
    @victordavila3642 ปีที่แล้ว

    Now I'm afraid to fail

  • @juampics
    @juampics ปีที่แล้ว

    good video, it was quite helpful. I was looking for how to delete the /media/ files but when the avatar in the profile is updated. In case it helps anyone, do it like this:
    def save(self, *args, **kwargs):
    # Delete the old file before saving the new one
    try:
    this = Avatar.objects.get(id=self.id)
    if this.image != self.image:
    this.image.delete(save=False)
    except Avatar.DoesNotExist:
    pass
    super(Avatar, self).save(*args, **kwargs)