Configure STATIC_URL and STATICFILES_DIRS in Django
📖 Scenario: You are building a Django website that needs to serve static files like images, CSS, and JavaScript. To do this, you must tell Django where to find these static files and how to refer to them in your templates.
🎯 Goal: Set up Django settings to define the URL path for static files and specify the folder where your static files are stored.
📋 What You'll Learn
Create a variable
STATIC_URL with the value '/static/' in settings.py.Create a list variable
STATICFILES_DIRS that includes the path BASE_DIR / 'static'.Use the
BASE_DIR variable which is already defined as the project base directory.Follow Django's recommended syntax for static files configuration.
💡 Why This Matters
🌍 Real World
Web developers use STATIC_URL and STATICFILES_DIRS to manage and serve static assets like stylesheets and images in Django projects.
💼 Career
Knowing how to configure static files is a basic but crucial skill for Django developers working on real websites.
Progress0 / 4 steps