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

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

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

  • @perpy7149
    @perpy7149 Месяц назад +1

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

    • @bugbytes3923
      @bugbytes3923  26 дней назад

      Thank you - I'm glad to hear that!

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

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

    Can't wait for the next video : )

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

    so excited for the next video!

  • @mikedodds9926
    @mikedodds9926 7 месяцев назад

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

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

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

    Can't wait for the next one!

  • @adityanjsg99
    @adityanjsg99 Месяц назад

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

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

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

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

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

    Very interesting tutorial thank you !

  • @thibaultledanois455
    @thibaultledanois455 Год назад

    Perfect tuto for me ! Thank you so much :)

    • @bugbytes3923
      @bugbytes3923  Год назад

      You're welcome - thanks for watching! :)

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

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

  • @mehdismaeili3743
    @mehdismaeili3743 9 месяцев назад +1

    Excellent.

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

    So cool!

  • @streamocu2929
    @streamocu2929 9 месяцев назад +1

    you are django hero

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

    super ❤❤❤❤❤❤ Thank You

  • @ali-cu1ne
    @ali-cu1ne 6 месяцев назад

    Ammmmmazing content ❤

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

    Thanks so much

    • @bugbytes3923
      @bugbytes3923  Год назад

      You’re welcome, thanks for the view!

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

  • @satwikawasthi2002
    @satwikawasthi2002 20 дней назад

    Where is front end part for submitting image?

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

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

  • @vivaldi-qo7xj
    @vivaldi-qo7xj Год назад +1

    Thnx.

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

    Thank you

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

  • @ayotundeakinwumi8847
    @ayotundeakinwumi8847 7 месяцев назад

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

  • @yurigorohov9575
    @yurigorohov9575 Год назад

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

  • @DevendraSingh-ow2xp
    @DevendraSingh-ow2xp 6 месяцев назад

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

  • @JustForFun1426-t4k
    @JustForFun1426-t4k 9 месяцев назад

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

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

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

  • @alimansimov1929
    @alimansimov1929 7 месяцев назад

    How to serve in production environment?

  • @aafan.kuware
    @aafan.kuware 7 месяцев назад

    28:45 yes, please make it.

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

  • @ashishbhopte8149
    @ashishbhopte8149 7 месяцев назад

    Thanks

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

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

  • @JustForFun1426-t4k
    @JustForFun1426-t4k 9 месяцев назад

    Thank y

  • @YT4ntertainment
    @YT4ntertainment 8 месяцев назад

    Good Shit.

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