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.
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 👍
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.
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.
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?
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?
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.
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.
@@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.
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.
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?
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.
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)