2👍
I don’t think it’s possible with the default router. So you should:
- implement a custom router (or use a third party package)
- or manually register your
/schemes/:id/optimize_by_location/:id
url (probably easier but less generic):
More info about this in django rest tutorial: Binding ViewSets to URLs explicitly
from django.conf.urls import patterns, url
from .views import MyViewSet
optimize_view = MyViewSet.as_view({'get': 'optimize_specific_location'},)
urlpatterns = [
url(r'^schemes/(?P<id>[0-9]+)/optimize_by_location/(?P<loc_id>[0-9]+)/$',
optimize_view),
]
Source:stackexchange.com