Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRandy Helvey
11,311 PointsDjango REST Framework | Create a Viewset and Router | Challenge 3 of 3
My URL pattern (api/v2/) is throwing an exception which is causing Objective 2 not to pass.
Challenge 3 of 3:
Lastly, you need to put the api_router into urlpatterns. Add a new url to urlpatterns. Make the regex be "^api/v2/", then include the .urls from api_router. Give it "apiv2" as the namespace.
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework import routers
from scorekeeper import views
api_router = routers.SimpleRouter()
api_router.register(r'players', views.PlayerViewSet)
urlpatterns = [
url(r'^api/v1/', include('scorekeeper.urls', namespace='scorekeeper')),
url(r'^api/v2/', include('api_router.urls', namespace='apiv2')),
]
1 Answer
Tatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 PointsDon't put api_routers.urls into quotes
url(r'^api/v2/', include(api_router.urls, namespace='apiv2')),