在中的同一函数中返回多个呈现视图.py在djang

2024-04-20 13:02:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我在django有问题。 事实上,我会返回许多render(请求,模板.html中的同一函数中视图.py;我指的是模板.html将被更改 有很多不同的值,每个值都在给定的时刻。在

代码视图.py公司名称:

def test(request):
    test1 = "true"
    test2 = "true"

    if test1 == "true":
        val= 50
        return render(request,'template.html', {'x':val})
    if test2 == "true":
        val= 20
        return render(request, 'template.html', {'x':val})

我会在第一个函数中,返回值50温度.html在页面20后返回其值。在

有人能帮我吗?在


Tags: 函数py视图模板truereturnifrequest
1条回答
网友
1楼 · 发布于 2024-04-20 13:02:30

我想。。。您希望在服务器和客户机之间异步发送或接收信号。在

如果这是你想要的,我认为有三种解决办法。在

我希望这会有帮助

相关问题 更多 >