Skip to content

Commit cce3134

Browse files
committed
Update to Django 2.0 Routing Syntax
Updated the code in tutorial part 6, "Using Routers", to Django 2.0 routing syntax using path().
1 parent 7e0ad92 commit cce3134

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

docs/tutorial/6-viewsets-and-routers.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
REST framework includes an abstraction for dealing with `ViewSets`, that allows the developer to concentrate on modeling the state and interactions of the API, and leave the URL construction to be handled automatically, based on common conventions.
44

55
`ViewSet` classes are almost the same thing as `View` classes, except that they provide operations such as `read`, or `update`, and not method handlers such as `get` or `put`.
6-
76
A `ViewSet` class is only bound to a set of method handlers at the last moment, when it is instantiated into a set of views, typically by using a `Router` class which handles the complexities of defining the URL conf for you.
87

98
## Refactoring to use ViewSets
@@ -116,7 +115,7 @@ Here's our re-wired `snippets/urls.py` file.
116115

117116
# The API URLs are now determined automatically by the router.
118117
urlpatterns = [
119-
url(r'^', include(router.urls))
118+
path('', include(router.urls)),
120119
]
121120

122121
Registering the viewsets with the router is similar to providing a urlpattern. We include two arguments - the URL prefix for the views, and the viewset itself.

0 commit comments

Comments
 (0)