![](/img/trans.png)
[英]I want to display data using ORM in django but only a query is being generated on my html webpage
[英]I want save data in sqlite Database, My Query not working in webpage But same code wroking fine in Django Shell
我試圖通過Views.py添加一些數據,但是它不能正常工作,但是在django shell中可以正常工作。
我的代碼:
username = request.POST['username']
bp = request.POST['bp']
bs = request.POST['bs']
height = request.POST['height']
weight = request.POST['weight']
temp = request.POST['temp']
datasaved = PatTest(Patient= Patient.objects.get(username=str(username)), BS=int(bs), BP=int(bp), PatHeight=float(height), PatientWeight=float(weight), BMI=BMICal(height, weight), TEMPA=int(temp))
print("Test")
datasaved.save()
終於解決了這個問題。 問題是BMI=BMICal(height, weight)
。 我只是用BMICal(float(height), float(weight))
因為它是Models類中的float Value,所以我在其中提到了
username = request.POST['username']
bp = request.POST['bp']
bs = request.POST['bs']
height = request.POST['height']
weight = request.POST['weight']
tempsd = request.POST['temp']
print(Patient.objects.get(username=str(username)).PatID)
datasaved = PatTest(Patient= Patient.objects.get(username=str(username)), BS=int(bs), BP=int(bp), PatHeight=float(height), PatientWeight=float(weight), BMI=BMICal(float(height), float(weight)), TEMPA=int(tempsd))
datasaved.save()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.