【发布时间】:2017-02-21 17:35:23
【问题描述】:
我有一个对用户进行身份验证的视图。如果用户通过了身份验证,程序应该以请求和用户作为参数调用另一个视图。
def home(request):
if request.method == "POST":
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user is not None:
return index(request, user)
else:
context = {'error_message': "That username and password don't exist in our system."}
return render(request, 'list/home.html', context)
所以,当 index 被调用时,请求与发送到主视图的请求是同一个实例,对吧?我担心的是,当它应该是 GET 请求时,它仍然是 POST 请求。
这是一种误解吗?我应该创建一个新的请求对象并将其发送到索引吗?
谢谢。
【问题讨论】:
标签: django django-views