二手車專案(四)

2022-04-29 02:09:11 字數 4382 閱讀 1313

'''新增到購物車

:param request:

:return:

'''#

驗證使用者是否登入

ifrequest.user.is_authenticated():

car_id = request.get['

carid']

print('

car_id-------------

', car_id)

try:

car = carinfo.objects.get(id=car_id)

picture = car.picture #

汽車 brand = str(car.serbran) + str(car.ctitle) #

汽車品牌型號

price = car.extractprice #

汽車**

mileage = car.mileage #

行駛里程

newprice = car.newprice #

新車**

'''取消訂單

'''確認訂單

:param request:

:return:

'''#

已經登入

ifrequest.user.is_authenticated():

car_id = request.get['

carid']

orderno = datetime.datetime.now().strftime('

%y%m%d%h%m%s')

cart = cart.objects.filter(car_id=car_id)[0]

car = carinfo.objects.filter(id=car_id)[0]

picture =cart.picture

brand =cart.brand

price =cart.price

mileage =cart.mileage

newprice =cart.newprice

sale_user =car.user

buy_user =request.user

#建立新的訂單物件

orders.objects.create(sale_user=sale_user, buy_user=buy_user, brand=brand, picture=picture, price=price,

newprice=newprice, mileage=mileage, orderno=orderno)

user_id =request.user.id

#查詢當前登入使用者的所有訂單

orders = orders.objects.filter(buy_user=user_id).order_by('

-id'

)

#查詢當前登入使用者資訊

user = users.objects.get(id=user_id)

#查詢當前登入使用者所賣的車

car = carinfo.objects.filter(user_id=user_id, ispurchase=0, isdelete=0)

return render(request, '

user-info.html

', )

else

:

return redirect('

/userinfo/login/

')

def

del_order(request):

'''取消訂單

'''確認訂單

:param request:

:return:

'''#

已經登入

ifrequest.user.is_authenticated():

car_id = request.get['

carid']

orderno = datetime.datetime.now().strftime('

%y%m%d%h%m%s')

cart = cart.objects.filter(car_id=car_id)[0]

car = carinfo.objects.filter(id=car_id)[0]

picture =cart.picture

brand =cart.brand

price =cart.price

mileage =cart.mileage

newprice =cart.newprice

sale_user =car.user

buy_user =request.user

#建立新的訂單物件

orders.objects.create(sale_user=sale_user, buy_user=buy_user, brand=brand, picture=picture, price=price,

newprice=newprice, mileage=mileage, orderno=orderno)

user_id =request.user.id

#查詢當前登入使用者的所有訂單

orders = orders.objects.filter(buy_user=user_id).order_by('

-id'

)

#查詢當前登入使用者資訊

user = users.objects.get(id=user_id)

#查詢當前登入使用者所賣的車

car = carinfo.objects.filter(user_id=user_id, ispurchase=0, isdelete=0)

return render(request, '

user-info.html

', )

else

:

return redirect('

/userinfo/login/

')

二手車專案(二)

sale應用中 urls.py 1 encoding utf 8 2 author freshman 3 4from django.conf.urls import url,include56 from sale import views78 9 urlpatterns 10 汽車品牌列表 11 u...

瓜子二手車推出二手車新零售業務

瓜子二手車今日宣布,正式推出二手車新零售業務 瓜子保賣體驗店,通過線上大資料 流量,線下實體店的聯動,實現交易效率大幅提公升的同時帶動交易規模的提公升。瓜子保賣體驗店 車輛均來自個人賣家,買賣雙方一口價交易。賣車車主可提前拿到瓜子先行墊付的大額預付車款,節約售車時間 買家可一次多看大量優質個人車源,...

天池二手車比賽 EDA

這是第二次的任務打卡 首先是基本流程 借鑑別人的乙個思維導圖,基本流程比較清楚了。1.與官方手冊有修改的的地方 import seaborn as sns import matplotlib.pyplot as plt import scipy.stats as st 引入科學計算包,統計類 plt...