-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrouters.py
More file actions
48 lines (42 loc) · 1.23 KB
/
routers.py
File metadata and controls
48 lines (42 loc) · 1.23 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
REST framework URL routing classes.
"""
from __future__ import unicode_literals
from rest_framework import routers
from rest_framework.routers import Route
class ApiRouter(routers.DefaultRouter):
"""Routes UUID interchangeably with owner/handle."""
routes = [
# List route.
Route(
url=r'^{prefix}/?$',
mapping={
'get': 'list',
'post': 'create'
},
name='{basename}-list',
initkwargs={'suffix': 'List'}
),
# Detail route.
Route(
url=r'^{prefix}/{lookup}/?$',
mapping={
'get': 'retrieve',
'put': 'update',
'patch': 'partial_update',
'delete': 'destroy'
},
name='{basename}-detail',
initkwargs={'suffix': 'Instance'}
),
# Dynamically generated routes, from @action or @link decorators
# on methods of the viewset.
Route(
url=r'^{prefix}/{lookup}/{methodname}/?$',
mapping={
'{httpmethod}': '{methodname}',
},
name='{basename}-{methodnamehyphen}',
initkwargs={}
),
]