0
0
Djangoframework~5 mins

Static files in development in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are static files in Django?
Static files are files like CSS, JavaScript, and images that don’t change dynamically and are served as they are to the browser.
Click to reveal answer
beginner
How does Django serve static files during development?
Django automatically serves static files when DEBUG is True using the built-in static files app, so you don’t need extra setup for development.
Click to reveal answer
intermediate
What setting tells Django where to find static files in your project?
The STATICFILES_DIRS setting lists folders where Django looks for static files during development.
Click to reveal answer
beginner
What is the purpose of the {% static %} template tag in Django?
The {% static %} tag helps you write URLs for static files in templates, so Django can find and serve them correctly.
Click to reveal answer
intermediate
Why should you not use Django’s static file serving in production?
Django’s static file serving is slow and not secure for production. Instead, use a web server like Nginx or a CDN to serve static files.
Click to reveal answer
Which setting controls whether Django serves static files automatically during development?
ADEBUG
BSTATIC_URL
CALLOWED_HOSTS
DINSTALLED_APPS
What does the STATICFILES_DIRS setting do?
ADefines the URL prefix for static files
BLists directories where Django looks for static files
CSpecifies the folder where collected static files are stored
DEnables static file compression
Which template tag is used to link to static files in Django templates?
A{% load static %} and {% static %}
B{% url %}
C{% include %}
D{% block %}
Where should you place your static files in a Django app for development?
AIn the templates folder
BIn the migrations folder
CIn the media folder
DInside the app’s static folder
Why is it recommended to use a web server like Nginx for static files in production?
ABecause Django can’t serve static files at all
BBecause Django only supports CSS files
CBecause web servers are faster and more secure for static files
DBecause static files need to be compiled first
Explain how Django handles static files during development and what settings are important.
Think about how Django finds and serves CSS or images when you run the development server.
You got /4 concepts.
    Describe why Django’s static file serving is not suitable for production and what should be done instead.
    Imagine your website gets many visitors; how do you serve images and styles fast and safely?
    You got /4 concepts.