0
0
Djangoframework~5 mins

STATIC_URL and STATICFILES_DIRS in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is STATIC_URL used for in Django?

STATIC_URL is the URL prefix used to serve static files like CSS, JavaScript, and images in a Django project. It tells the browser where to find these files.

Click to reveal answer
beginner
What does STATICFILES_DIRS do in Django settings?

STATICFILES_DIRS is a list of folders where Django looks for additional static files during development, besides the static folders inside each app.

Click to reveal answer
intermediate
How do STATIC_URL and STATICFILES_DIRS work together?

STATICFILES_DIRS tells Django where to find static files on your computer, and STATIC_URL tells the browser the URL path to access those files.

Click to reveal answer
beginner
Why should STATIC_URL usually end with a slash (/)?

Ending STATIC_URL with a slash ensures URLs for static files are formed correctly, like /static/css/style.css, avoiding broken links.

Click to reveal answer
beginner
Where do you typically set STATIC_URL and STATICFILES_DIRS in a Django project?

Both are set in the settings.py file of your Django project to configure static file handling.

Click to reveal answer
What type of value is STATIC_URL in Django settings?
AA list of directories
BA Python function
CA boolean flag
DA URL path string
Which setting tells Django where to find extra static files on your computer?
ASTATIC_URL
BSTATICFILES_DIRS
CMEDIA_ROOT
DINSTALLED_APPS
If you want your static files to be served at /assets/, what should STATIC_URL be set to?
A"/assets/"
B"assets/"
C"/assets"
D"assets"
Where do you configure STATIC_URL and STATICFILES_DIRS?
Aurls.py
Bviews.py
Csettings.py
Dmodels.py
Which of these is NOT a purpose of STATICFILES_DIRS?
ATo define the URL prefix for static files
BTo tell Django where to collect static files
CTo help during development to find static files
DTo list extra folders with static files
Explain in your own words what STATIC_URL and STATICFILES_DIRS do in a Django project.
Think about how the browser finds static files and where Django looks for them on your computer.
You got /3 concepts.
    Describe how you would set up static files in a Django project using STATIC_URL and STATICFILES_DIRS.
    Imagine telling Django where your static files live and how users can access them.
    You got /4 concepts.