from django.core import serializers
from django.http import HttpResponse, JsonResponse
from Profiler.models import *
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST, require_GET
import json

@csrf_exempt
@require_POST
def addStudent(request):
	response_data = {}
	try:
		S = Student.objects.addStudent(request.POST)
	except Exception as e:
		response_data['success'] = '0'
		response_data['exception'] = str(e)
	else :
		response_data['success'] = '1'
		data = serializers.serialize('json', [ S, ])
		response_data["student"] = json.loads(data)
	return JsonResponse(response_data)

@csrf_exempt
@require_POST
def editStudent(request):
	response_data = {}
	try:
		S = Student.objects.editStudent(request.POST)
	except Exception as e:
		response_data['success'] = '0'
		response_data['exception'] = str(e)
	else :
		response_data['success'] = '1'
		data = serializers.serialize('json', [ S, ])
		response_data["student"] = json.loads(data)
	return JsonResponse(response_data)

@csrf_exempt
@require_POST
def deleteStudent(request):
	response_data = {}
	try:
		S = Student.objects.deleteStudent(request.POST)
	except Exception as e:
		response_data['success'] = '0'
		response_data['exception'] = str(e)
	else :
		response_data['success'] = '1'
		data = serializers.serialize('json', [ S, ])
		response_data["student"] = json.loads(data)
	return JsonResponse(response_data)

@csrf_exempt
@require_GET
def getStudentByRollNo(request):
	response_data = {}
	try:
		S = Student.objects.getStudentByRollNo(request.GET)
	except Exception as e:
		response_data["success"] = 0
		response_data['exception'] = str(e)
	else:
		response_data["success"] = 1
		data = serializers.serialize('json', [ S, ])
		response_data["student"] = json.loads(data)
		del response_data["student"][0]["fields"]["password"]

	return JsonResponse(response_data)


"""
def searchStudent(request):
    

def getStudentsByName(request):


def getStudentsByDegree(request):


def getStudentsByBranch(request):

"""

@@ -1950,16 +1950,606 @@
 ata)%0D%0A%0D%0A
+@csrf_exempt%0D%0A@require_GET%0D%0Adef retrieveProjects(request):%0D%0A    response_data = %7B%7D%0D%0A    try:%0D%0A        C = Project.objects.retrieveProjects(request.GET)%0D%0A    except Exception as e:%0D%0A        response_data%5B'success'%5D = '0'%0D%0A        response_data%5B'exception'%5D = str(e)%0D%0A    else:%0D%0A        response_data%5B'success'%5D = '1'%0D%0A        global data%0D%0A        try:%0D%0A            data = serializers.serialize('json', C)%0D%0A        except Exception as e:%0D%0A            data = serializers.serialize('json', %5BC, %5D)%0D%0A        response_data%5B%22projects%22%5D = json.loads(data)%0D%0A%0D%0A    return JsonResponse(response_data)%0D%0A
 %0D%0A%22%22%22%0D%0Ad

Update Student.py