编程语言
首页 > 编程语言> > 【项目实战】Python基于Django框架实现校园网上一站式购物系统

【项目实战】Python基于Django框架实现校园网上一站式购物系统

作者:互联网

说明:这是一个web实战项目(附带软件+代码+文档+视频讲解),如需软件+代码+文档+视频讲解可以直接到文章最后获取。

视频展示:

<iframe allowfullscreen="true" data-mediaembed="bilibili" id="eOTMIChp-1644319145603" src="https://player.bilibili.com/player.html?aid=211446530"></iframe>

【项目实战】Python基于Django框架实现校园网上一站式购物系统

系统功能

关键代码

from django.views.static import serve
from rest_framework.documentation import include_docs_urls

import xadmin
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.generic import TemplateView
from VueDjangoFrameWorkShop.settings import MEDIA_ROOT
from goods.views import GoodsListViewSet, CategoryViewset, BannerViewset, IndexCategoryViewset, HotSearchsViewset
from trade.views import ShoppingCartViewset, OrderViewset, AlipayView
from user_operation.views import UserFavViewset, LeavingMessageViewset, AddressViewset
from users.views import SmsCodeViewset, UserViewset
# from goods.views import GoodsListView,
# from goods.views_base import GoodsListView
from rest_framework.routers import DefaultRouter
from rest_framework.authtoken import views
from rest_framework_jwt.views import obtain_jwt_token

# goods_list = GoodsListViewSet.as_view({
#     'get': 'list',
# })
router = DefaultRouter()

# 配置goods的url,这个basename是干啥的
router.register(r'goods', GoodsListViewSet, basename="goods")

# 配置Category的url
router.register(r'categorys', CategoryViewset, basename="categorys")

# 配置codes的url
router.register(r'code', SmsCodeViewset, basename="code")

# 配置users的url
router.register(r'users', UserViewset, basename="users")

# 配置用户收藏的url
router.register(r'userfavs', UserFavViewset, basename="userfavs")

# 配置用户留言的url
router.register(r'messages', LeavingMessageViewset, basename="messages")

# 收货地址
router.register(r'address', AddressViewset, basename="address")

# 购物车
router.register(r'shopcarts', ShoppingCartViewset, basename="shopcarts")

# 订单相关url
router.register(r'orders', OrderViewset, basename="orders")

# 首页banner轮播图url
router.register(r'banners', BannerViewset, basename="banners")

# 首页系列商品展示url
router.register(r'indexgoods', IndexCategoryViewset, basename="indexgoods")

# 热搜词
router.register(r'hotsearchs', HotSearchsViewset, basename="hotsearchs")

# from VueDjangoFrameWorkShop.settings import STATIC_ROOT

urlpatterns = [
    # path('admin/', admin.site.urls),
    path('xadmin/', xadmin.site.urls),
    # 处理图片显示的url,使用Django自带serve,传入参数告诉它去哪个路径找,我们有配置好的路径MEDIAROOT
    re_path('media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT }),
    # 富文本相关url
    path('ueditor/', include('DjangoUeditor.urls')),

    # 商品列表页
    # path('goods/', GoodsListView.as_view(),name="goods-list"),
    # path('goods/', goods_list,name="goods-list"),

    # router的path路径
    re_path('^', include(router.urls)),
    # 自动化文档,1.11版本中注意此处前往不要加$符号
    path('docs/', include_docs_urls(title='文档')),
    # 调试登录
    path('api-auth/', include('rest_framework.urls')),

    # drf自带的token授权登录,获取token需要向该地址post数据
    path('api-token-auth/', views.obtain_auth_token),

    # jwt的token认证
    path('login/', obtain_jwt_token),

    # 支付宝支付相关接口
    path('alipay/return/', AlipayView.as_view()),

    # 首页
    path('index/', TemplateView.as_view(template_name='index.html'), name='index'),

    # re_path('static/(?P<path>.*)', serve, {"document_root": STATIC_ROOT}),

    # 第三方登录
    path('', include('social_django.urls', namespace='social'))
]

本次机器学习项目实战所需的资料,项目资源如下:

项目说明:
链接:https://pan.baidu.com/s/1GdYxoF7I-u8raYD3QW5toA 
提取码:dueh

网盘如果失效,可以添加博主微信:zy10178083

标签:goods,Python,import,basename,register,Django,router,校园网,path
来源: https://blog.csdn.net/weixin_42163563/article/details/122829544