hi, currently i am doing booking car online and one of the function is cancel and update booking. if the booking number users entered in is not exist. it will redirect the page stating that the booking number did not exist or you never book with us. however. i would like to express this "if Not exist" concept in my coding. how should i achieve this. the following is my code:
[code=python]
def deleteCar(reque st):
if request.user.is _authenticated( ):
Login = True
myId=request.se ssion['B_id']
my = Booking1.object s.get(id= myId)
IF NOT EXIST my:
return HttpResponseRed irect ("/nobooking/")
else:
dateStr=my.book ing_time
now=datetime.da tetime.now()
print now
one_day=60*60*2 4
diff=comp_dates (dateStr,str(no w).split('.')[0])
print diff
if diff > one_day:
return HttpResponseRed irect ("/unable/")
if diff < one_day:
my.delete()
else:
return HttpResponseRed irect ("/Deny/")
return render_to_respo nse('confirmed_ cancel.html')
[/code]
the IF NOT EXIST is just my concept in the coding, can any one help me with code..thanks so much. ;)
[code=python]
def deleteCar(reque st):
if request.user.is _authenticated( ):
Login = True
myId=request.se ssion['B_id']
my = Booking1.object s.get(id= myId)
IF NOT EXIST my:
return HttpResponseRed irect ("/nobooking/")
else:
dateStr=my.book ing_time
now=datetime.da tetime.now()
print now
one_day=60*60*2 4
diff=comp_dates (dateStr,str(no w).split('.')[0])
print diff
if diff > one_day:
return HttpResponseRed irect ("/unable/")
if diff < one_day:
my.delete()
else:
return HttpResponseRed irect ("/Deny/")
return render_to_respo nse('confirmed_ cancel.html')
[/code]
the IF NOT EXIST is just my concept in the coding, can any one help me with code..thanks so much. ;)
Comment