15 lines
614 B
Python
15 lines
614 B
Python
from rest_framework import permissions, status
|
|
from ..serializers.register import RegisterSerialiser
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from django.http import HttpRequest
|
|
|
|
class RegisterView(APIView):
|
|
permission_classes = (permissions.AllowAny,)
|
|
def post(self, request: HttpRequest):
|
|
serializer = RegisterSerialiser(data=request.POST)
|
|
if serializer.is_valid(raise_exception=True):
|
|
user = serializer.create(request.POST)
|
|
if user:
|
|
return Response("user created", status=status.HTTP_201_CREATED)
|
|
return Response(status=status.HTTP_400_BAD_REQUEST) |