django - 如何将计算变量保存在 django 数据库中并在之后加载?
问题描述
我正在制作一个简单的计算应用程序,但我想将计算的变量保存在数据库中,以便在需要时加载它们。谢谢
def showvideo(request):
allvideos = Video.objects.all()
form = VideoForm(request.POST or None)
if form.is_valid():
sirina = form.cleaned_data.get('sirina')
visina = form.cleaned_data.get('visina')
category = form.cleaned_data.get('category')
roletne = form.cleaned_data.get('roletne')
okapnice = form.cleaned_data.get('okapnice')
materijal = form.cleaned_data.get('materijal')
komore = form.cleaned_data.get('komore')
krila = form.cleaned_data.get('krila')
#Example
a = 20 + sirina
b = 30 + visina
c = 50 + roletne
## I want to save those variables in database and load them after
## in template
form.save()
context={'form':form}
return render(request,'index.html',context)
解决方案
推荐阅读
- javascript - JQuery在文本末尾单击时删除完整链接
- c++ - 修改 value const 方法
- mongodb - Mongodb - 如果元素不在数据库中,如何使用 $inc
- google-apps-script - 更新 A 列中的单元格时创建新工作表
- javascript - 返回数字 x 的前 n 倍数
- android - 在 Android 9 或更高版本中无法从 BroadcastReceiver 启动 Activity
- three.js - 使用 A-Frame 和 Three.js 实现视频透明度
- android - Android Kotlin:让 ScrollBar 到达顶部
- azure-devops - 在 WIQL 上优化搜索
- c# - 如何通过注册的域为 Asp.Net Web 应用程序访问配置 Nginx