hi, currently i am doing a car rental website, once it is bigger tthan 1 day's time which is 24 hours, its inventory will be updated and only admin can executed this. However if it is smaller than 24 hours, then it will still remain at the current inventory. the car's booking time is inside my Booking1 table and car_inventory is inside CarModel table.
[code=python]
def inventory(reque st):
allObj=[]
for i in Booking1.object s.all():
#print i.booking_time
invtime=i.booki ng_time
t=str(invtime). split('.')[0]
now=datetime.da tetime.now()
one_day=60*60*2 4
diff=comp_dates (t,str(now).spl it('.')[0])
print diff
if diff>one_day:
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 diff>one_day:
return render_to_respo nse("inventory. html")
[/code]
as for this code, it don not error but i never go through my if not condition even through it fulfills this condition. can anyone help me with this, thus it will go through this "if not diff>one_day:" condition.thank s so much for kind help :)
[code=python]
def inventory(reque st):
allObj=[]
for i in Booking1.object s.all():
#print i.booking_time
invtime=i.booki ng_time
t=str(invtime). split('.')[0]
now=datetime.da tetime.now()
one_day=60*60*2 4
diff=comp_dates (t,str(now).spl it('.')[0])
print diff
if diff>one_day:
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 diff>one_day:
return render_to_respo nse("inventory. html")
[/code]
as for this code, it don not error but i never go through my if not condition even through it fulfills this condition. can anyone help me with this, thus it will go through this "if not diff>one_day:" condition.thank s so much for kind help :)
Comment