1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| from django.conf.urls import url, include from myApp.views import StudentViewSet, UserViewSet from rest_framework.urlpatterns import format_suffix_patterns
student_list = StudentViewSet.as_view({ 'get': 'list', 'post': 'create', }) student_detail = StudentViewSet.as_view({ 'get': 'retrieve', 'put': 'update', 'patch': 'partial_update', 'delete': 'destroy', })
user_list = UserViewSet.as_view({ 'get': 'list', }) user_detail = UserViewSet.as_view({ 'get': 'retrieve', })
urlpatterns = format_suffix_patterns([ url(r'^students/$', student_list, name='studentList'), url(r'^students/(?P<pk>\d+)', student_detail, name='studentDetail'), url(r'^users/$', user_list, name='userList'), url(r'^users/(?P<pk>\d+)', user_detail, name='userDetail'), ])
|