My view.py looks as follows. I think the error is in this section. I will post a detailed function if this is not sufficient for now. Basically the model that takes total as argument is of type integer.
我的观点。py看起来如下。我认为错误在这一部分。如果现在还不够,我将发布一个详细的函数。基本上作为参数的模型是整数类型。
Edit 1: Writing the entire function so that it can be more helpful.
编辑1:编写整个函数,这样会更有帮助。
def subjManip(request):
c= {}
c.update(csrf(request))
subj = None
c.update(csrf(request))
if request.method == 'POST':
form = SubjForm(request.POST)
if form.is_valid():
user = request.user
subj1 = form.cleaned_data['subj1']
subj2 = form.cleaned_data['subj2']
subj3 = form.cleaned_data['subj3']
if subj1 == None and subj2 == None:
raise forms.ValidationError("Both subjs cannot be empty")
tot = float (((float(0.2017 * subj1 )+ float (0.09036 * subj2) + float(0.6309 * subj3) - 5.0269)/ 4.184)
total =int(tot)
elif subj1 == None:
total = subj1
1 个解决方案
#1
1
Try replacing tot = (subj1+subj2)/2.2
with tot = (float(subj1) + float(subj2)) / 2.2
试着用tot = (float(subj1) + float(subj2)))/2.2替换tot = (float(subj1) + float(subj2)) /2.2
#1
1
Try replacing tot = (subj1+subj2)/2.2
with tot = (float(subj1) + float(subj2)) / 2.2
试着用tot = (float(subj1) + float(subj2)))/2.2替换tot = (float(subj1) + float(subj2)) /2.2