📌 #11 - Django Templates and Images | Django Templates and Images | Add Images Using Static Folder

Опубликовано: 07 Июль 2026
на канале: Guhan Tech Zone
273
4

🖼️ Django Templates and Images Tutorial

In this video, you will learn how to use templates and display images in Django. We explain how to create a static folder, upload images, configure MEDIA_ROOT and MEDIA_URL, and display images inside a Django HTML template.

👶 This tutorial is very useful for beginners learning Django web development.

📌 Django Templates and Images – Step by Step

🗂️ Step 1: Create Static Folder

Inside your project directory, create a folder named:

📁 static
↳ 📁 images

📤 Upload any image inside the images folder.

⚙️ Step 2: Configure settings.py

Open settings.py and add the following configuration:

MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')
MEDIA_URL = '/images/'

📌 This tells Django where images are stored and how they should be accessed.

📝 Step 3: Create HTML Template

Create a file called test.html inside the templates folder.

🖼️ Step 4: Add Image Path in Template

Use the image path using MEDIA_URL inside your HTML file.

📍 Image path format:
/images/your_image_name.jpg

🔁 Step 5: Load Template from View

Return the template from your Django view using the render function.

▶️ Step 6: Run Server and Test

python manage.py runserver

🌐 Open the browser and check your page.
✅ The image will be displayed successfully.

💡 Why Templates and Images Are Important in Django?

✔ Build dynamic web pages
✔ Add media content to websites
✔ Improve UI and user experience
✔ Required for real-world projects

django templates tutorial
django add images
django static folder
django media root media url
django html templates
python django web development

#Django
#DjangoTemplates
#DjangoImages
#StaticFiles
#PythonDjango
#WebDevelopment
#LearnDjango
#DjangoTutorial