views.py 如下:
class RegisterView(generics.GenericAPIView,
mixins.CreateModelMixin,):
queryset = User.objects.all()
serializer_class = UserSerializer
def post(self, request, *args, **kwargs):
username = request.POST.get('username')
password = request.POST.get('password')
User.objects.create_user(username=username,
password=password)
return Response('create user success!!')
urls.py 如下:
router = DefaultRouter()
urlpatterns = [
path('', include(router.urls)),
path('register/',views.RegisterView.as_view()), ]
想把 registerview 放到 defaultrouter 中,求解