urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.BookGenericView.as_view({'get': 'login'})),
]
views.py
class BookGenericView(ModelViewSet):
@action(methods=['get'],detail=False)
def login(self, request, *args, **kwargs):
return Response(data="登录成功")