Skip to content

Instantly share code, notes, and snippets.

@mansha99
Created July 4, 2023 17:36
Show Gist options
  • Save mansha99/08dbd890a65cb5a7c7c172b0ba57ef61 to your computer and use it in GitHub Desktop.
Save mansha99/08dbd890a65cb5a7c7c172b0ba57ef61 to your computer and use it in GitHub Desktop.
notice_app/notices/views/user/py
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