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.

Example 9.40: Project Code

blog/urls.py in 3fc0ec56de

 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.