在我的视图函数中,我想返回一个json对象(data1)和一些text / html(窗体)。这可能吗?
我的密码
@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')
当我调用该网址时,我收到状态代码500,显示错误,如下所示
TemplateDoesNotExist rest_framework / api.html
当我检查为API时,得到200正常状态的响应。这表明我无法获取我的HTML页面
我应该如何根据请求获取我的HTML
提前致谢