Update to Django 2.0 Routing Syntax (#6049)

This commit is contained in:
Chris Shyi 2018-06-22 04:28:59 -04:00 committed by Carlton Gibson
parent 1a170438d2
commit d9f541836b

View File

@ -105,7 +105,7 @@ Because we're using `ViewSet` classes rather than `View` classes, we actually do
Here's our re-wired `snippets/urls.py` file.
from django.conf.urls import url, include
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from snippets import views
@ -116,7 +116,7 @@ Here's our re-wired `snippets/urls.py` file.
# The API URLs are now determined automatically by the router.
urlpatterns = [
url(r'^', include(router.urls))
path('', include(router.urls)),
]
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.