0
0
Djangoframework~10 mins

Why static file management matters in Django - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the directory for static files in Django settings.

Django
STATIC_URL = '/static/'
STATICFILES_DIRS = [[1]]
Drag options to blanks, or click blank then click option'
A'/var/www/static/'
BBASE_DIR / 'static'
CBASE_DIR / 'media'
D'staticfiles/'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the media folder path instead of static folder.
Using a string path without BASE_DIR.
2fill in blank
medium

Complete the code to collect static files into a single directory for deployment.

Django
python manage.py [1]
Drag options to blanks, or click blank then click option'
Acollectstatic
Brunserver
Cmigrate
Dstartapp
Attempts:
3 left
💡 Hint
Common Mistakes
Using runserver instead of collectstatic.
Confusing with migrate command.
3fill in blank
hard

Fix the error in the template tag to load static files correctly.

Django
{% load [1] %}
<img src="{% static 'images/logo.png' %}" alt="Logo">
Drag options to blanks, or click blank then click option'
Astatic
Bmedia
Cstaticfiles
Dfiles
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'media' instead of 'static'.
Using 'staticfiles' which is incorrect in templates.
4fill in blank
hard

Fill both blanks to configure static root and URL in Django settings for production.

Django
STATIC_URL = '[1]'
STATIC_ROOT = BASE_DIR / '[2]'
Drag options to blanks, or click blank then click option'
A/static/
B/media/
Cstaticfiles
Dmediafiles
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing media URL with static URL.
Using 'mediafiles' for static root.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension filtering static files by extension.

Django
static_files = {file: path for file, path in files.items() if file.endswith([1]) or file.endswith([2]) or file.endswith([3])}
Drag options to blanks, or click blank then click option'
A'.css'
B'.js'
C'.png'
D'.txt'
Attempts:
3 left
💡 Hint
Common Mistakes
Including '.txt' which is not a typical static asset.
Missing one of the main static file types.