0
0
Djangoframework~10 mins

Serving media in development in Django - Interactive Code Practice

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

Complete the code to import the function needed to serve media files in development.

Django
from django.conf.urls.static import [1]
Drag options to blanks, or click blank then click option'
Apath
Bserve
Curl
Dstatic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' instead of 'static' for importing.
Confusing 'url' or 'path' as the import from this module.
2fill in blank
medium

Complete the code to add media URL patterns in development using the imported function.

Django
urlpatterns += [1](settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Drag options to blanks, or click blank then click option'
Astatic
Bserve
Cpath
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' which is a view, not a function to add URL patterns.
Using 'path' or 'include' which are unrelated here.
3fill in blank
hard

Fix the error in the condition to serve media files only in development mode.

Django
if settings.DEBUG [1] True:
Drag options to blanks, or click blank then click option'
Ais
B=
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using single '=' which is assignment, causing syntax error.
Using 'is' which is identity check and not recommended for boolean comparison.
4fill in blank
hard

Fill both blanks to complete the import and settings references for serving media files.

Django
from django.conf import [1]

urlpatterns += static(settings.[2], document_root=settings.MEDIA_ROOT)
Drag options to blanks, or click blank then click option'
Asettings
BMEDIA_URL
Curls
DMEDIA_ROOT
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'urls' instead of 'settings' for import.
Confusing 'MEDIA_ROOT' with 'MEDIA_URL' in the URL pattern.
5fill in blank
hard

Fill all three blanks to complete the typical pattern for serving media files in development.

Django
if settings.DEBUG:
    urlpatterns += [1](settings.[2], document_root=settings.[3])
Drag options to blanks, or click blank then click option'
Astatic
BMEDIA_URL
CMEDIA_ROOT
Dserve
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' instead of 'static' to add URL patterns.
Mixing up 'MEDIA_URL' and 'MEDIA_ROOT' in the arguments.