Created
July 4, 2023 17:36
-
-
Save mansha99/08dbd890a65cb5a7c7c172b0ba57ef61 to your computer and use it in GitHub Desktop.
notice_app/notices/views/user/py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import JsonResponse | |
from ..serializers import RegisterSerializer | |
from rest_framework.decorators import api_view | |
from django.views.decorators.csrf import csrf_exempt | |
from rest_framework import status | |
@csrf_exempt | |
@api_view(['POST']) | |
def createAccount(request): | |
serializer = RegisterSerializer(data=request.data) | |
if serializer.is_valid(): | |
serializer.save() | |
return JsonResponse(status=status.HTTP_200_OK, data=serializer.data) | |
else: | |
return JsonResponse(status=status.HTTP_422_UNPROCESSABLE_ENTITY, data=serializer.errors) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment