0
0
Djangoframework~10 mins

urlpatterns list structure 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 define URL patterns.

Django
from django.urls import [1]
Drag options to blanks, or click blank then click option'
Apath
Binclude
Curl
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' instead of 'path' for defining individual URL patterns.
Using 'url' which is deprecated in modern Django versions.
2fill in blank
medium

Complete the code to define a simple URL pattern that maps the root URL to a view named 'home_view'.

Django
urlpatterns = [
    [1]('', home_view, name='home'),
]
Drag options to blanks, or click blank then click option'
Ainclude
Bpath
Curl
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' instead of 'path' for direct view mapping.
Using 'url' which is outdated.
3fill in blank
hard

Fix the error in the URL pattern by completing the code to correctly include another URLconf module named 'blog.urls'.

Django
urlpatterns = [
    path('blog/', [1]('blog.urls')),
]
Drag options to blanks, or click blank then click option'
Ainclude
Bpath
Curl
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'path' instead of 'include' to include other URL modules.
Using 'url' which is deprecated.
4fill in blank
hard

Fill both blanks to create a URL pattern that maps 'about/' to a view called 'about_view' with the name 'about'.

Django
urlpatterns = [
    [1]('[2]', about_view, name='about'),
]
Drag options to blanks, or click blank then click option'
Apath
Binclude
Cabout/
Dhome/
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' instead of 'path' for direct view mapping.
Using 'home/' instead of 'about/' as the URL path.
5fill in blank
hard

Fill all three blanks to create a URL pattern that maps 'contact/' to a view called 'contact_view' with the name 'contact'.

Django
urlpatterns = [
    [1]('[2]', [3], name='contact'),
]
Drag options to blanks, or click blank then click option'
Apath
Bcontact/
Ccontact_view
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' instead of 'path' for direct view mapping.
Mixing up the URL path string and the view function.