Permalink
Browse files

Wire rest_framework router to URLs

  • Loading branch information...
andrewdotn committed Aug 20, 2016
1 parent bef198f commit 727df519b9163ed73354f878a68e21d15c9bf598
Showing with 9 additions and 2 deletions.
  1. +2 −0 polls_rest/config/settings.py
  2. +7 −2 polls_rest/polls/urls.py
@@ -45,6 +45,8 @@ def load_secret_key():
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'rest_framework',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@@ -1,13 +1,18 @@
from django.conf.urls import url
from django.conf.urls import include, url
from rest_framework import routers
from . import views
api_router = routers.DefaultRouter()
api_router.register(r'questions', views.QuestionViewSet)
app_name = 'polls'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'),
url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
url(r'^api/questions/$', views.QuestionViewSet.as_view({'get': 'list'}))
url(r'^api/', include(api_router.urls))
]

0 comments on commit 727df51

Please sign in to comment.