Skip to content

Routers

rn_forge.django.drf.routers

A DRF router that spells extra actions as AIP-136 custom methods.

CustomMethodRouter(*args, **kwargs)

Bases: DefaultRouter

A :class:~rest_framework.routers.DefaultRouter with colon-form custom methods.

An @action(detail=False, url_path="batchCreate") is served at /orders:batchCreate and an @action(detail=True, url_path="cancel") at /orders/12:cancel. Custom methods never take a trailing slash. The default lookup pattern excludes :, so GET /orders/12:nope is a 404 rather than a retrieve of "12:nope"; a viewset's own lookup_value_regex overrides it.

Example::

router = CustomMethodRouter()
router.register("orders", OrderViewSet, basename="orders")
urlpatterns = router.urls