def setUp(self): self.factory = APIRequestFactory() self.view = UserViewSet.as_view({'get': 'list', 'post': 'create'}) self.url = '/api/accounts/'
# -*- coding: utf-8 -*- from django.conf.urls import url from accounts.api.views import UserViewSet user_list = UserViewSet.as_view({ 'get': 'list', }) user_detail = UserViewSet.as_view({ 'get': 'retrieve', 'put': 'update', 'patch': 'partial_update', 'delete': 'destroy' }) urlpatterns = [ url(r'^(?P<organisation>[\w-]+)/(?P<category>[\w-]+)/$', user_list, name='user-list'), url(r'^(?P<organisation>[\w-]+)/(?P<category>[\w-]+)/(?P<pk>\d+)/$', user_detail, name='user-detail'), ]
# -*- coding: utf-8 -*- from django.conf.urls import patterns, url from accounts.api.views import UserViewSet user_list = UserViewSet.as_view({ 'get': 'list', }) user_detail = UserViewSet.as_view({ 'get': 'retrieve', 'put': 'update', 'patch': 'partial_update', 'delete': 'destroy' }) urlpatterns = patterns( '', url(r'^(?P<organisation>[\w-]+)/(?P<category>[\w-]+)/$', user_list, name='user-list'), url(r'^(?P<organisation>[\w-]+)/(?P<category>[\w-]+)/(?P<pk>\d+)/$', user_detail, name='user-detail'), )
from accounts.api.views import UserList from accounts.api.views import UserViewSet from django.urls import path from rest_framework.authtoken.views import obtain_auth_token urlpatterns = [ path('list/', UserList.as_view({'get': 'list'}), name='user_list'), path('users/<pk>/', UserViewSet.as_view({'get': 'retrieve'}), name='user_view'), path('obtain-token/', obtain_auth_token, name='auth_token'), ]