django之post开发的问题
来源:3-3 django之post接口开发

weibo_紫轩小飞侠_0
2018-08-18
def login(request):
if request.method == "POST":
username = request.POST.get('username')
return HttpResponse(username + '-post 接口测试')
else:
return render_to_response('login.html')
老师,后面的这句: else: return render_to_response('login.html') ,一定要吗,这个是什么意思?
写回答
1回答
-
你好,这个你可以不要,但是如果你不要你可以看一下你还能打开登陆页面么?你可以这样理解,如果请求时post请求,然后把里面数据返回,如果不是就返回登陆页面。
022018-10-15
相似问题