Commit 0f04271d authored by Ashish's avatar Ashish
Browse files

Add router for read-only APIs

parent 6e6b2c87
from rest_framework.routers import DefaultRouter
from rest_framework.routers import Route
class ReadOnlyRouter(DefaultRouter):
"""
A router for read-only APIs, which USES trailing slashes.
"""
routes = [
Route(url=r'^{prefix}{trailing_slash}$',
mapping={'get': 'list'},
name='{basename}-list',
initkwargs={'suffix': 'List'}),
Route(url=r'^{prefix}/{lookup}{trailing_slash}$',
mapping={'get': 'retrieve'},
name='{basename}-detail',
initkwargs={'suffix': 'Detail'})
]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment