0
0
Djangoframework~10 mins

URL parameter type converters 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 capture an integer parameter named 'year' in the URL pattern.

Django
path('archive/<[1]:year>/', views.archive, name='archive')
Drag options to blanks, or click blank then click option'
Astr
Buuid
Cint
Dslug
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'str' instead of 'int' which captures any string, not just numbers.
Using 'slug' which matches letters, numbers, underscores or hyphens.
2fill in blank
medium

Complete the code to capture a slug parameter named 'post_slug' in the URL pattern.

Django
path('post/<[1]:post_slug>/', views.post_detail, name='post_detail')
Drag options to blanks, or click blank then click option'
Aslug
Bint
Cuuid
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'int' which only matches numbers.
Using 'uuid' which expects a UUID format.
3fill in blank
hard

Fix the error in the URL pattern to correctly capture a UUID parameter named 'user_id'.

Django
path('user/<[1]:user_id>/', views.user_profile, name='user_profile')
Drag options to blanks, or click blank then click option'
Auuid
Bstr
Cslug
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'str' which matches any string but does not validate UUID format.
Using 'int' which only matches numbers.
4fill in blank
hard

Fill both blanks to capture a string parameter 'username' and an integer parameter 'page' in the URL pattern.

Django
path('profile/<[1]:username>/page/<[2]:page>/', views.profile_page, name='profile_page')
Drag options to blanks, or click blank then click option'
Astr
Bint
Cslug
Duuid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'slug' for username which may exclude some characters.
Using 'str' for page which should be an integer.
5fill in blank
hard

Fill all three blanks to create a URL pattern capturing a slug 'category', an integer 'year', and a UUID 'item_id'.

Django
path('shop/<[1]:category>/<[2]:year>/<[3]:item_id>/', views.shop_item, name='shop_item')
Drag options to blanks, or click blank then click option'
Aslug
Bint
Cuuid
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up converters like using 'str' for year or 'int' for UUID.
Using 'slug' for year which expects numbers.