6
考慮簡單的觀點:嵌套detail_route
class SomeView(viewsets.GenericViewSet,
viewsets.mixins.ListModelMixin,
viewsets.mixins.RetrieveModelMixin):
...
@decorators.detail_route(methods=ENDPOINT_PROPERTY_METHODS)
def some_property(self, request, *args, **kwargs):
view = SomeOtherView
return view.as_view(CRUD_ACTIONS)(request, *args, **kwargs)
我打電話SomeOtherView
必須有一個終結點屬性一樣/someresource/:id/myproperty
能力,所以這個屬性將接受請求,並可以做所有CRUD動作。
但是,我想SomeOtherView
也有內部申報detail_route
有像/someresource/:id/myproperty/nestedproperty
。
由於我動態調用SomeOtherView
,因此無法註冊URL,因此無法調用嵌套屬性。
我如何解決這種情況具有嵌套屬性?