我试图将manage_quota
和govt_quota
存储到我的模型choice_filling
中,但错误表明没有定义上述命名变量。如何在数据库中存储这些值
这是my views.py(已更新)
def seat_info(request):
if request.method == "POST":
institute_code = request.POST['institute_code']
seats = request.POST['seates']
# s75 = int(seats) * 75 / 100
s25 = int(seats) * (25 / 100)
# s25 = int(float(seats) * (25.0 / 100.0))
print("25% is ", s25)
mq = request.POST['manage_quota']
mq15 = int(float(s25) * (15.0 / 100.0))
print("15% is ", mq15)
# mq = float(mq) / 15.0
if float(mq) > 15.0:
return HttpResponse('not allowed')
manage_quota = int(s25 * float(mq)/100)
gov = request.POST['govt_quota']
gov10 = int(float(s25) * (10.0 / 100.0))
# gov = float(gov) / 10.0
print("10% is ", gov10)
if float(gov) > 10.0:
return HttpResponse('not allowed')
govt_quota = int(s25 * float(gov)/100)
clg_id = request.POST['clg_id']
fees = request.POST['fees']
course = request.POST['course']
s = seat_metrix(clg_id_id=clg_id, code=institute_code, total_seats=seats,
course_id=course, manage_quota=manage_quota, govt_quota=govt_quota, fees=fees)
s.save()
return redirect('college-dashboard')
strm = streams.objects.all()
title = "Seat Information"
page = "Seat Registration"
return render(request, 'seat_info.html', {'strm': strm, 'title': title, 'page': page})
以及错误回溯(更新) 现在我面临着这个错误
Internal Server Error: /admission/seat-info
Traceback (most recent call last):
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Dell\PycharmProjects\AdmissionSystem\Admission\users\views.py", line 378, in seat_info
course_id=course, govt_quota=govt_quota, manage_quota=manage_quota, fees=fees)
UnboundLocalError: local variable 'govt_quota' referenced before assignment
更新:
问题解决了!我知道这是dirtyfix,但它工作得很好
这会使工作完成
if float(gov) > 10.0:
return HttpResponse('not allowed')
govt_quota = int(s25 * float(gov)/100)
我已经更新了我的views.py
目前没有回答
相关问题 更多 >
编程相关推荐