Recall & Review
beginner
What do angle brackets <> mean in Django URL patterns?
Angle brackets <> in Django URL patterns mark a variable part of the URL. They capture a value from the URL and pass it as a parameter to the view function.
Click to reveal answer
beginner
How do you capture an integer parameter named 'id' in a Django URL pattern?
Use <int:id> inside the URL pattern. This captures an integer from the URL and names it 'id' for the view to use.
Click to reveal answer
beginner
What happens if you use <str:name> in a Django URL pattern?
It captures any text (except slashes) from the URL and passes it as a string parameter named 'name' to the view.
Click to reveal answer
intermediate
Can you use custom converters with angle brackets in Django URLs?
Yes, Django allows custom path converters to define how URL parts are matched and converted before passing to views.
Click to reveal answer
intermediate
Why is it better to use typed parameters like <int:id> instead of just <id>?
Typed parameters ensure the URL part matches the expected type (like integer), preventing errors and improving URL clarity.
Click to reveal answer
What does <slug:post_slug> do in a Django URL pattern?
✗ Incorrect
<slug:post_slug> captures a slug string which includes letters, numbers, underscores, or hyphens.
Which of these is the correct way to capture a username as a string in Django URL?
✗ Incorrect
Use <str:username> to capture any string without slashes as the username.
What will happen if you use <int:id> but the URL has a non-integer value?
✗ Incorrect
Django returns a 404 error if the URL part does not match the expected type.
How do you define a URL pattern that captures a UUID parameter named 'uid'?
✗ Incorrect
Use <uuid:uid> to capture a UUID in Django URLs.
Which part of Django handles the matching of URL parameters with angle brackets?
✗ Incorrect
The URL dispatcher in urls.py matches URL patterns and extracts parameters.
Explain how angle brackets are used to capture parameters in Django URL patterns.
Think about how URLs can include changing parts like IDs or names.
You got /4 concepts.
Describe why using typed parameters like is helpful in Django URLs.
Consider what happens if a URL expects a number but gets text.
You got /4 concepts.