9.3.1 Creating a View to Modify Post
Objects
To uniquely identify a Post
, we need a year, a month, and a slug. However, if we simply identify the object, we will be in conflict with our blog_post_detail
URL pattern. We need to differentiate our new blog_post_update
URL from blog_post_detail
, so we append the /update/
path segment to the regular expression pattern, anticipating the creation of PostUpdate
, as shown in Example 9.40.
3 from .views import ( 4 PostCreate, PostList, PostUpdate, post_detail) . ... 6 urlpatterns = [ . ... 18 url(r'^(?P<year>\d{4})/' 19 r'(?P<month>\d{1,2})/' 20 r'(?P<slug>[\w\-]+)/' ...
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.