hi
currently i am doing this car booking website. i would like to only update our inventory one day before customer's start booking time, thus before that, i am still able to rent to other customers. E.g. if she book two month before, i can still rent this car to others within this 2 month, but one day before i need to deduct this car inventory as the next day i have to give this car to that customer.
the following is my car inventory update function. but it seems did not work in my way, as i loop through my Booking1 table to get all the start_datetime and update my inventory only if it is one day before this start_datetime. my start_datetime is in the format of "2007-12-21 17:05:05", i have changed it into seconds by using Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S")). but it seems not work. can anyone help me with this. can update my car inventory only one day before the start_datetime. thanks for any kind help:)
[code=python]
def inventory(reque st):
allObj=[]
for i in Booking1.object s.all():
#print i.booking_time
invtime=i.start _datetime
#t=str(invtime) .split('.')[0]
Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S"))
#now=datetime.d atetime.now()
one_day=60*60*2 4
#diff=comp_date s(t,str(now).sp lit('.')[0])
#print diff
onebefore=Bktim e-one_day------>>>Error,wher e is wrong?date type?
if str(onebefore):
for a in CarModel.object s.all():
qtyInStock=a.ca r_inventory
orderQuantity = 1
qtyLeft = int(qtyInStock) - int(orderQuanti ty)
a.car_inventory =qtyLeft
a.save()
allObj=CarModel .objects.all()
print allObj
print "LLLLLLLLLLLLLL LLLL"
return render_to_respo nse("inventoryu pdate.html", {'allObj':allOb j})
if not str(onebefore):
all=CarModel.ob jects.all()
return render_to_respo nse("inventory. html",{'all':al l})
[/code]
currently i am doing this car booking website. i would like to only update our inventory one day before customer's start booking time, thus before that, i am still able to rent to other customers. E.g. if she book two month before, i can still rent this car to others within this 2 month, but one day before i need to deduct this car inventory as the next day i have to give this car to that customer.
the following is my car inventory update function. but it seems did not work in my way, as i loop through my Booking1 table to get all the start_datetime and update my inventory only if it is one day before this start_datetime. my start_datetime is in the format of "2007-12-21 17:05:05", i have changed it into seconds by using Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S")). but it seems not work. can anyone help me with this. can update my car inventory only one day before the start_datetime. thanks for any kind help:)
[code=python]
def inventory(reque st):
allObj=[]
for i in Booking1.object s.all():
#print i.booking_time
invtime=i.start _datetime
#t=str(invtime) .split('.')[0]
Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S"))
#now=datetime.d atetime.now()
one_day=60*60*2 4
#diff=comp_date s(t,str(now).sp lit('.')[0])
#print diff
onebefore=Bktim e-one_day------>>>Error,wher e is wrong?date type?
if str(onebefore):
for a in CarModel.object s.all():
qtyInStock=a.ca r_inventory
orderQuantity = 1
qtyLeft = int(qtyInStock) - int(orderQuanti ty)
a.car_inventory =qtyLeft
a.save()
allObj=CarModel .objects.all()
print allObj
print "LLLLLLLLLLLLLL LLLL"
return render_to_respo nse("inventoryu pdate.html", {'allObj':allOb j})
if not str(onebefore):
all=CarModel.ob jects.all()
return render_to_respo nse("inventory. html",{'all':al l})
[/code]
Comment