根据反射做,
按钮 value 要设置成统一的, 这里是 submit
class BOM(View):
def dispatch(self, request, *args, **kwargs):
if request.method.lower() in self.http_method_names:
if request.method.lower()=='post':
for key,value in request.POST.items():
if value=='submit':
handler=getattr(self, key, self.http_method_not_allowed)
else:
handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
return handler(request, *args, **kwargs)
def get(self,request):
return render(request,'bom.html')
def F1(self,request): #name为F1的按钮
print('f1 ok ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;')
return render(request, 'bom.html')
def F2(self,request):
print('f2 ok ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;')
return render(request, 'bom.html')
def F3(self,request):
print('f3 ok ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;')
return render(request, 'bom.html')