Static files in development
📖 Scenario: You are building a simple Django website that needs to show a logo image and apply some basic styles using CSS. To do this, you must set up static files correctly so Django can find and serve your CSS and image files during development.
🎯 Goal: Set up Django static files configuration and create a simple HTML page that loads a CSS file and displays an image from the static folder.
📋 What You'll Learn
Create a
STATIC_URL setting in settings.pyCreate a folder named
static inside your Django appAdd a CSS file and an image file inside the
static folderLoad static files in the Django template using the
{% load static %} tagUse the
{% static %} template tag to link the CSS and image filesEnsure the development server serves static files correctly
💡 Why This Matters
🌍 Real World
Websites often need to serve images, stylesheets, and scripts. Proper static file setup ensures these assets load correctly during development.
💼 Career
Understanding static files is essential for Django developers to build visually appealing and functional web applications.
Progress0 / 4 steps