How to use Cloudinary with Django Application for uploading Images.

Aditya Mali
1 min readMay 11, 2021

Why not to use Django for serving Static files in Production?

Django is not as fast or efficient while serving static files, most of the larger web applications use dedicated server or services like AWS S3 / Cloudinary for serving static file which helps in loading these files much faster.

In this post we are using Cloudinary for serving static files to our web application so lets get started.

Lets say you need to upload images to the server so in your models.py file nothing different to do over there its the same way you do it all the time.

image = models.ImageField(upload_to='Portfolio/', null=True)

Therefore, to use cloudinary in your application first, you will need to install the cloudinary package using the following command.

pip install cloudinary dj3-cloudinary-storage

Now let us add some settings and connect our application to cloudinary.

Open your settings.py file and add cloudinary in your installed apps section

INSTALLED_APPS = [ ...
'cloudinary',
]

Now, at the bottom of your settings.py add your Cloudinary identifiers as below that you will get after signing up on Cloudinary.

CLOUDINARY_STORAGE = {'CLOUD_NAME': 'Your Cloud Name','API_KEY': 'Your API KEY','API_SECRET': 'Your Secret Key',}DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

Thats all you have successfully connected your application with cloudinary

--

--