Exactly what I was looking. Say I want a particular field in my model (posts=models.FileField(upload_to='posts') to accept both video and image files, how do I implement this?
@devmaesters Жыл бұрын
Hi, the code you wrote should work posts=models.FileField(upload _to='posts') Because Filefield is meant to handle different media types.
@Ease_and_Plenty Жыл бұрын
@@devmaesters From the documentation and your tutorial, we must specify the type of file we want to upload to cloudinary using the DEFAULT_FILE_STORAGE variable. Say i set this to the VideoMediaCloudinaryStorage, if i upload an image file on the field example i gave above, it would through an error. Setting the storage=MediaCloudinaryStorage() as an attribute on the field in the model would mean it'll take only image fields right. But what I want is that particular field to upload either image or video files to cloudinary.
@devmaesters Жыл бұрын
Hi, sorry for replying late. I'll try to use a Field like this in a dummy project today and test it out myself. I will let you know how it goes 👍.
@devmaesters Жыл бұрын
@jonahebute9135 Check out this post I wrote on how to upload images and videos from the same field in Django devmaesters.com/blog/46