Python图书商城(可运行代码)有说明文档
生活随笔
收集整理的這篇文章主要介紹了
Python图书商城(可运行代码)有说明文档
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?前端使用了Django框架,結(jié)合sqlite數(shù)據(jù)庫,且具有項目配置文檔說明,實踐項目小白專屬。
可運行,歡迎購買,留言可以免費指導配置。
可在線模擬整個購書過程,并且主頁包含了基于圖書(商品)自身的協(xié)同過濾推薦算法對圖書進行推薦。
完整的前后臺模式,實現(xiàn)管理員對圖書進行管理。
【部分代碼實現(xiàn)】
片段1:
def index(request):# 查詢各個分類的最新4條,最熱4條數(shù)據(jù)typelist = TypeInfo.objects.all()# _set 連表操作type0 = typelist[0].goodsinfo_set.order_by('-id')[0:4] # 圖書的ID號,按照上傳順序自動排序type01 = typelist[0].goodsinfo_set.order_by('-gclick')[0:4] # 按照點擊量type1 = typelist[1].goodsinfo_set.order_by('-id')[0:4]type11 = typelist[1].goodsinfo_set.order_by('-gclick')[0:4]type2 = typelist[2].goodsinfo_set.order_by('-id')[0:4]type21 = typelist[2].goodsinfo_set.order_by('-gclick')[0:4]type3 = typelist[3].goodsinfo_set.order_by('-id')[0:4]type31 = typelist[3].goodsinfo_set.order_by('-gclick')[0:4]type4 = typelist[4].goodsinfo_set.order_by('-id')[0:4]type41 = typelist[4].goodsinfo_set.order_by('-gclick')[0:4]type5 = typelist[5].goodsinfo_set.order_by('-id')[0:4]type51 = typelist[5].goodsinfo_set.order_by('-gclick')[0:4]increase=GoodsInfo.objects.all().order_by('-gclick')[5:10]cart_num = 0# 判斷是否存在登錄狀態(tài)# if request.session.has_key('user_id'):if 'user_id' in request.session:user_id = request.session['user_id']cart_num = CartInfo.objects.filter(user_id=int(user_id)).count()context = {'title': '首頁','cart_num': cart_num,'guest_cart': 1,'type0': type0, 'type01': type01,'type1': type1, 'type11': type11,'type2': type2, 'type21': type21,'type3': type3, 'type31': type31,'type4': type4, 'type41': type41,'type5': type5, 'type51': type51,'increase': increase,}return render(request, 'df_goods/index.html', context)片段2:
def good_list(request, tid, pindex, sort):# tid:商品種類信息 pindex:商品頁碼 sort:商品顯示分類方式typeinfo = TypeInfo.objects.get(pk=int(tid))news = typeinfo.goodsinfo_set.order_by('-id')[0:2]goods_list = []cart_num, guest_cart = 0, 0try:user_id = request.session['user_id']except:user_id = Noneif user_id:guest_cart = 1cart_num = CartInfo.objects.filter(user_id=int(user_id)).count()if sort == '1': # 默認最新goods_list = GoodsInfo.objects.filter(gtype_id=int(tid)).order_by('-id')elif sort == '2': # 按照價格goods_list = GoodsInfo.objects.filter(gtype_id=int(tid)).order_by('-gprice')elif sort == '3': # 按照人氣點擊量goods_list = GoodsInfo.objects.filter(gtype_id=int(tid)).order_by('-gclick')# 創(chuàng)建Paginator一個分頁對象paginator = Paginator(goods_list, 4)# 返回Page對象,包含圖書信息page = paginator.page(int(pindex))context = {'title': '商品列表','guest_cart': guest_cart,'cart_num': cart_num, #購物車編號'page': page, #頁數(shù)'paginator': paginator, #分頁對象'typeinfo': typeinfo, #類別'sort': sort, # 排序方式'news': news,}return render(request, 'df_goods/list.html', context)【實現(xiàn)效果圖】
?
源代碼下載地址:https://download.csdn.net/download/qq_40129714/20432370
總結(jié)
以上是生活随笔為你收集整理的Python图书商城(可运行代码)有说明文档的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java数据类型 枚举_枚举(enum)
- 下一篇: python显示invalid char