Created
February 1, 2022 16:21
-
-
Save Soyuzbek/afbcfce1b9d116c48bc549486ee53eed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.routers import SimpleRouter, Route, DynamicRoute | |
class LookupFreeRouter(SimpleRouter): | |
routes = [ | |
# CRUD route. | |
Route( | |
url=r'^{prefix}{trailing_slash}$', | |
mapping={ | |
'get': 'retrieve', | |
'post': 'create', | |
'put': 'update', | |
'patch': 'partial_update', | |
'delete': 'destroy' | |
}, | |
name='{basename}-list, create, update, partial update', | |
detail=False, | |
initkwargs={'suffix': 'CRUD'} | |
), | |
# Dynamically generated action routes. Generated using | |
# @action(detail=False) decorator on methods of the viewset. | |
DynamicRoute( | |
url=r'^{prefix}/{url_path}{trailing_slash}$', | |
name='{basename}-{url_name}', | |
detail=False, | |
initkwargs={} | |
), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment