1 回答

TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
在分配返回值之前檢查返回值怎么樣?
def updateCustomer(request):
current = request.user
if request.method == 'POST':
newphone = request.POST['number']
newemail = request.POST['email']
newname = request.POST['name']
curCust = Customer.objects.get(user=current)
if newphone:
curCust.phone = newphone
if newemail:
curCust.email = newemail
if newname:
curCust.name = newname
if newphone or newemail or newname:
curCust.save()
return redirect('home')
添加回答
舉報(bào)