How to integrate Cloudinary with a Django project in 5 mins.

Saiyad Faizan Ali
1 min readFeb 19, 2021

--

Without wasting anytime I will directly share the steps and code needed to integrate Cloudinary to your Django project.

Step 1 : Go to https://cloudinary.com/users/register/free and create a free account. It will prompt for a cloud name which should be your project name or it will give an auto-generated name.

Step 2: On the home page copy the cloud_name, api_key and api_secret. For example: cloud_name = ‘sample-cloud’ , api_key = ‘14589637892758’ , api_secret = ‘dfjibi#JFIdbv-Kfe&fjWfQ’ .

Step 3: Activate your virtual environment and run

pip install cloudinary.

Step 4: Paste the below code at the top of your python file wherever you are going to use Cloudinary and paste your credentials in the respective manner.

import cloudinarycloudinary.config( 
cloud_name = “sample”,
api_key = “874837483274837”,
api_secret = “a676b67565c6767a6767d6767f676fe1”
)

Here cloudinary will be used for calling the methods provided by Cloudinary. If you change it then use the new reference in below commands.

Step 5: For folder creation use the following code:

import cloudinarycloudinary.config( 
cloud_name = “sample”,
api_key = “874837483274837”,
api_secret = “a676b67565c6767a6767d6767f676fe1”
)
cloudinary.api.create_folder(“folder_name/subfolder_name”)

Step 6: For file uploading:

import cloudinarycloudinary.config( 
cloud_name = “sample”,
api_key = “874837483274837”,
api_secret = “a676b67565c6767a6767d6767f676fe1”
)
cloudinary.uploader.upload(‘local path or online url of the file to be uploaded', folder = “_______/”, public_id = “_____”)

Note: If you don’t enter folder name than it will upload in the root folder. Give a public id why which you want the file to be identified whenever you search or retrieve it. Also folder and public_id are optional parameters.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Saiyad Faizan Ali
Saiyad Faizan Ali

Written by Saiyad Faizan Ali

0 Followers

I am a Python Developer. I want to share my experiences so that others get solutions for the generic problems without any haste.

No responses yet

Write a response