0
0
Djangoframework~10 mins

Including app URLs 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 include function needed to include app URLs.

Django
from django.urls import path, [1]
Drag options to blanks, or click blank then click option'
Aurl
Binclude
Creverse
Dredirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'include' which is deprecated.
Forgetting to import 'include' causes errors when including URLs.
2fill in blank
medium

Complete the code to include the app URLs under the 'blog/' path.

Django
urlpatterns = [
    path('blog/', [1]('blog.urls')),
]
Drag options to blanks, or click blank then click option'
Apath
Bredirect
Cinclude
Dreverse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'path' instead of 'include' causes errors because 'path' expects a view.
Forgetting to wrap the app URL string in the include function.
3fill in blank
hard

Fix the error in the code to correctly include the app URLs.

Django
urlpatterns = [
    path('shop/', [1]),
]

# 'shop.urls' is missing the include function.
Drag options to blanks, or click blank then click option'
A'shop.urls'
Bredirect('shop.urls')
Creverse('shop.urls')
Dinclude('shop.urls')
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the string directly without include causes Django to treat it as a view, leading to errors.
Using other functions like reverse or redirect which are not for including URLs.
4fill in blank
hard

Fill both blanks to include the 'accounts' app URLs with a namespace.

Django
urlpatterns = [
    path('accounts/', [1]('accounts.urls', namespace=[2])),
]
Drag options to blanks, or click blank then click option'
Ainclude
B'accounts'
C'accounts_ns'
Dpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'path' instead of 'include' for including URLs.
Setting namespace to a variable or wrong string.
5fill in blank
hard

Fill all three blanks to include the 'store' app URLs with a namespace and a name for the path.

Django
urlpatterns = [
    path('[1]/', [2]('store.urls', namespace=[3]), name='store_home'),
]
Drag options to blanks, or click blank then click option'
Astore
Binclude
C'store'
Dshop
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the first blank path segment.
Using wrong function instead of include.
Setting namespace to a variable instead of a string.