【发布时间】:2020-03-17 06:43:57
【问题描述】:
如何在基于单个函数的视图中添加两个渲染。我不知道这可以做到,如果不能,请提供另一种方法。
views.py
def success(request):
return render(request, "tools/loading.html", {})
#Raspberry pi code
print("on")
pin13.write(1)
time.sleep(2)
print("off")
pin13.write(0)
return render(request, "tools/booked.html", {})
目前它不会运行树莓派代码,它直接返回页面并在第一次渲染时跳过其余代码。
但我需要更新此代码,以便在调用此基于“成功”函数的视图时它应该返回“loading.html”,在执行 Raspberry pi 代码后它应该返回另一个页面。所有这些都应该在后端完成。
【问题讨论】:
标签: django django-views