0
0
Djangoframework~10 mins

URL namespacing 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 include the app URLs with a namespace in the main urls.py.

Django
path('blog/', include(('blog.urls', '[1]'))),
Drag options to blanks, or click blank then click option'
Anamespace
Bname
Capp_name
Durl_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'app_name' instead of 'namespace' in include()
Omitting the namespace argument
Using 'name' which is not valid here
2fill in blank
medium

Complete the app's urls.py to define the app_name for namespacing.

Django
app_name = '[1]'
Drag options to blanks, or click blank then click option'
Anamespace
Bmain
Curls
Dblog
Attempts:
3 left
💡 Hint
Common Mistakes
Setting app_name to 'urls' or 'namespace'
Leaving app_name undefined
Using a different name than the app folder
3fill in blank
hard

Fix the error in reversing a namespaced URL in a Django template.

Django
{% url '[1]:post_detail' post.id %}
Drag options to blanks, or click blank then click option'
Apost_detail
Bblog
Cdetail
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using the URL name without the namespace
Using the URL name as the namespace
Omitting the colon
4fill in blank
hard

Fill both blanks to include app URLs with namespace and set app_name in app urls.py.

Django
path('shop/', include(('shop.urls', '[1]')))

app_name = '[2]'
Drag options to blanks, or click blank then click option'
Ashop
Bstore
Cmain
Dproducts
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for namespace and app_name
Using unrelated strings
Leaving app_name undefined
5fill in blank
hard

Fill all three blanks to correctly namespace URLs and reverse a URL in a Django view.

Django
urlpatterns = [
    path('', views.index, name='[1]'),
]

app_name = '[2]'

url = reverse('[3]:index')
Drag options to blanks, or click blank then click option'
Aindex
Bblog
Cshop
Dhome
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching app_name and namespace
Using wrong URL name in reverse
Omitting app_name