Grokking Django
0% completed
Working with URL Routing in Django
How does Django decide that a request for /blog/5/ belongs to the view that shows article 5? The answer is a short search through lists of URL patterns, called URL resolution. Knowing the exact order of that search explains most routing surprises: a pattern that never matches, a URL that reaches the wrong view, or a 404 for a page that seems to exist.
How Django Matches a URL
The blog app from the previous lesson gets two new views, one for the list of articles and one for a single article:
# blog/views.py from django.http import HttpResponse def blog_home(request):
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%