5.10.1 Directing the Homepage with URL Configurations
The first and perhaps most obvious way would be to create a new URL pattern to send the route to the view we have already built. In /suorganizer/urls.py
, we could add the URL pattern shown in Example 5.73 to the URL configuration.
suorganizer/urls.py
in 3ddb5f3810
20 from blog.views import PostList . ... 23 urlpatterns = [ 24 url(r'^$', 25 PostList.as_view()), . ... 29 ]
The regular expression pattern: ^
starts the pattern, while $
ends the pattern. This matches ''
, which is what the root of the URL is to Django, given that it always strips the first /
.
Similarly, given that the PostList
view is the root ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.