I have django rest framework api application and generate documentation for it. I use api view with viewset and I have custom method. In urls I use routers. For generate documentation I use DRF Docs.
My view:
class UserViewSet(viewsets.ModelViewSet):
"""View for user object.
"""
...
@detail_route(methods=["post"])
def set_password(self, request, pk=None):
"""View to set new password
"""
...
urls:
from django.conf.urls import url, include
from rest_framework.routers import DefaultRouter
from accounts.views import UserViewSet
__all__ = ["accounts_urlpatterns"]
accounts_router = DefaultRouter()
accounts_router.register(r'users', UserViewSet)
accounts_urlpatterns = [
url(r'^accounts/', include(accounts_router.urls))
]
I want custom comments for set_password method and display different fields because I use for this method other serializer. How can I do that?