O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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\-]+)/' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required