我想在 Django 中更改渲染参数,但是,通过调用重定向方法。
def abc(request):
theatre = Theatre.objects.all()
return render(request, 'book_tickets/post_list.html', {'theatre':theatre, 'flag': False})
我还有另一个 xyz 函数,我想在其中执行如下操作:
def xyz(request):
if (something):
return redirect('post_list', 'flag':True)
请您参考如下方法:
使用kwargs发送变量
def abc(request, **kwargs):
try:
flag = kwargs['flag']
except:
flag = False
theatre = Theatre.objects.all()
return render(request, 'book_tickets/post_list.html', {'theatre':theatre, 'flag': flag})
