In my view function, I'd like to return a json object (data1) and some text/html (form). Is this possible?
MY code
@api_view(['POST'])
@permission_classes((AllowAny,))
def create_user(request):
if request.is_ajax():
if request.method == 'POST':
serializer = SignupSerializer(data=request.data)
print 'ser'
print serializer
if not serializer.is_valid():
return Response(serializer.errors,\
status=status.HTTP_400_BAD_REQUEST)
else:
serializer.save()
data={'status': 'Created','message': 'Verification email has been sent to your email. Please verify your account.'}
return Response(data, template_name='register.html')
else:
return HttpResponse('hello world')
When I call the url I get status code 500 with error as displayed below
TemplateDoesNotExist rest_framework/api.html
when I check as a API, I get response with 200 ok status. This shows Im unable to get my html page
How should I get my html depending on request
Thanks in advance
Make sure you have rest_framework
in your settings's INSTALLED_APPS