|
|
@@ -1,5 +1,7 @@
|
|
|
+from django.contrib.auth import get_user_model
|
|
|
from django.contrib.auth.models import User
|
|
|
-from rest_framework import viewsets
|
|
|
+from rest_framework import viewsets, permissions
|
|
|
+from rest_framework.generics import CreateAPIView
|
|
|
from rest_framework.response import Response
|
|
|
from rest_framework.views import APIView
|
|
|
|
|
|
@@ -14,6 +16,14 @@ class UserViewSet(viewsets.ModelViewSet):
|
|
|
serializer_class = UserSerializer
|
|
|
|
|
|
|
|
|
+class CreateUserView(CreateAPIView):
|
|
|
+ model = get_user_model()
|
|
|
+ permission_classes = [
|
|
|
+ permissions.AllowAny # Or anon users can't register
|
|
|
+ ]
|
|
|
+ serializer_class = UserSerializer
|
|
|
+
|
|
|
+
|
|
|
class CurrentUserView(APIView):
|
|
|
"""
|
|
|
"""
|
|
|
@@ -25,4 +35,4 @@ class CurrentUserView(APIView):
|
|
|
}
|
|
|
serializer = CurrentUserSerializer(user, context=serializer_context)
|
|
|
# return Response({"user": serializers.serialize('json', [ user, ])})
|
|
|
- return Response(serializer.data)
|
|
|
+ return Response(serializer.data)
|