CSS, JavaScript, and images live in static files—separate from templates and user uploads. Django collects them for production with collectstatic.
Development setup
- App static folder:
blog/static/blog/style.css STATIC_URL = '/static/'in settings- Load in templates:
{% load static %}then<link href="{% static 'blog/style.css' %}">
Production
python manage.py collectstatic copies files to STATIC_ROOT; nginx or whitenoise serves them efficiently. User uploads use MEDIA_URL/MEDIA_ROOT—different from static assets.
Important interview questions and answers
- Q: STATIC vs MEDIA?
A: STATIC is developer assets (CSS/JS); MEDIA is user-uploaded content (avatars, documents). - Q: Why collectstatic?
A: Production servers serve one consolidated directory—not scattered app folders. - Q: DEBUG=True static serving?
A: Django dev server serves static when configured; production needs whitenoise or nginx.
Self-check
- Where do you put app-specific CSS?
- What command prepares static files for production?