二手車專案(二)

2022-04-29 02:12:05 字數 4022 閱讀 7936

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 url(r'

^brandlist/$

',views.brandlist,name='

brandlist'),

12#汽車**列表

13 url(r'

^price0_10/$

', views.price0_10, name='

price0_10'),

14 url(r'

^price10_30/$

', views.price10_30, name='

price10_30'),

15 url(r'

^price30_80/$

', views.price30_80, name='

price30_80'),

16 url(r'

^price80_/$

', views.price80_, name='

price80_'),

17#汽車詳情

18 url(r'

^detail/$

', views.detail, name='

detail'),

1920 ]

sale-views.py

def

brandlist(request):

'''汽車品牌分類檢視

'''#

try 捕獲物件不存在異常

try:

#接受主頁傳遞的brand

brand = request.get['

brand']

#查詢所有品牌資訊列表

brand_list =brand.objects.all()

#通過品牌名稱獲取對應的品牌物件

brand = brand.objects.get(btitle=brand)

#查詢brand下的所有未刪除和銷售的車輛資訊列表

car_list = brand.carinfo_set.filter(ispurchase=0, isdelete=0)

#將傳遞給模板的變數封裝到字典中

'''汽車**分類

'''#

取得頁面get請求值

brand = request.get['

brand']

brand_list =brand.objects.all()

#如果brand為none

if brand == '

none':

ifpricehigh:

car_list = carinfo.objects.filter(isdelete=0, ispurchase=0, price__gt=pricelow, price__lte=pricehigh)

else

: car_list = carinfo.objects.filter(isdelete=0, ispurchase=0, price__gt=pricelow)

else

: brand = brand.objects.get(btitle=brand)

ifpricehigh:

car_list = brand.carinfo_set.filter(isdelete=0, ispurchase=0, price__gt=pricelow, price__lte=pricehigh)

else

: car_list = brand.carinfo_set.filter(isdelete=0, ispurchase=0, price__gt=pricelow)

params =

resp = render(request, '

list.html

', params)

return

resp

defprice0_10(request):

'''price0_10

:param request:

:return:

'''return price_car(request, 0, 10)

defprice10_30(request):

'''price10_30

:param request:

:return:

'''return price_car(request, 10, 30)

defprice30_80(request):

'''price30_80

:param request:

:return:

'''return price_car(request, 30, 80)

defprice80_(request):

'''price80_

:param request:

:return:

'''return price_car(request, 80, 9999999999) #

>>>>>>>>>//有問題

defdetail(request):

'''汽車詳情

'''首頁

:param request:

:return:

'''#

查詢所以品牌資訊

brand_list =brand.objects.all()

#查詢所有熱賣車型:取出5條待賣車輛記錄

car_list = carinfo.objects.filter(ispurchase=0,isdelete=0)

car_five = random.sample(list(car_list), 5)

return render(request, '

index.html

', locals())

sale-view.py

def

detail(request):

'''汽車詳情

二手車專案(四)

新增到購物車 param request return 驗證使用者是否登入 ifrequest.user.is authenticated car id request.get carid print car id car id try car carinfo.objects.get id car ...

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

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

天池二手車比賽 EDA

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