Exercise 1: Full RESTful Routes for a "posts" Resource — Possible Solution ==================================================================== RAILS (config/routes.rb) ------------------------------ resources :posts One line, generating all 7 real RESTful routes at once, following Rails' own naming convention exactly the way the chapter's own :users example did. DJANGO (urls.py) ------------------------------ from django.urls import path from . import views urlpatterns = [ path('posts/', views.post_index, name='post_index'), path('posts/new/', views.post_new, name='post_new'), path('posts/', views.post_create, name='post_create'), # same path, POST method path('posts//', views.post_show, name='post_show'), path('posts//edit/', views.post_edit, name='post_edit'), path('posts//', views.post_update, name='post_update'), # same path, PATCH/PUT path('posts//', views.post_destroy, name='post_destroy'), # same path, DELETE ] Django's own path() registers by URL pattern, not by (method, path) pair -- so three of these lines share a path with another line and are only distinguished at the view-function level by checking request.method, matching the chapter's own "HTTP Method Dispatch" material from Chapter 2. THE REAL 7 ROUTES PRODUCED, EITHER WAY ------------------------------ GET /posts index -- list all posts GET /posts/new new -- form for a new post POST /posts create -- create a post GET /posts/:id show -- show one post GET /posts/:id/edit edit -- form to edit a post PATCH /posts/:id update -- update a post PUT /posts/:id update -- update a post (same action, alternate method) DELETE /posts/:id destroy -- delete a post WHY THIS WORKS AS AN ANSWER ---------------------------- It reproduces the chapter's own real 7-route table for a genuinely different resource name, shows both the one-line Rails convention version and the fully-explicit Django version side by side, and calls out directly why three of the Django lines share an identical URL pattern -- the same point the chapter's own Chapter 2 already established about routing needing to key on method and path together, not path alone.