0
0
Djangoframework~10 mins

Reverse URL resolution with reverse 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 used for reverse URL resolution in Django.

Django
from django.urls import [1]
Drag options to blanks, or click blank then click option'
Apath
Breverse
Curl
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'path' instead of 'reverse'.
Trying to import 'url' which is deprecated.
2fill in blank
medium

Complete the code to reverse the URL named 'home'.

Django
url = reverse('[1]')
Drag options to blanks, or click blank then click option'
Ahome
Bindex
Cdashboard
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using a URL path instead of the URL name.
Misspelling the URL name.
3fill in blank
hard

Fix the error in reversing a URL that requires an argument 'pk'.

Django
url = reverse('detail', args=[[1]])
Drag options to blanks, or click blank then click option'
A1
Bpk
C'id'
Dobject
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the string 'pk' instead of a value.
Passing a variable name without quotes.
4fill in blank
hard

Fill both blanks to reverse a URL named 'profile' with a keyword argument 'username'.

Django
url = reverse('[1]', kwargs={{'[2]': 'john'}})
Drag options to blanks, or click blank then click option'
Aprofile
Buser
Cusername
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong URL name.
Using incorrect keyword argument key.
5fill in blank
hard

Fill all three blanks to reverse a URL named 'article-detail' with keyword arguments 'year' and 'slug'.

Django
url = reverse('[1]', kwargs={{'[2]': 2024, '[3]': 'django-tutorial'}})
Drag options to blanks, or click blank then click option'
Aarticle-detail
Byear
Cslug
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong URL name.
Using incorrect keys like 'date' instead of 'year'.
Swapping 'slug' and 'year' keys.