第十一节:插入轮播图

插入轮播图

一、添加路由

urls.py中添加

path('upload_swiper/', views.upload_swiper, name='upload_swiper')

二、添加视图函数

views.py中添加

def upload_swiper(request):
    if request.method == 'POST':
        file = request.FILES.get('swiper_img')
        url = request.POST.get('url')
        title = request.POST.get('title')
        models.Swiper.objects.create(image=file, img_url=url, title=title)
        return redirect(reverse('upload_swiper'))
    elif request.method == 'GET':
        swiper_list = models.Swiper.objects.all()
        return render(request, 'other/UploadSwiper.html', {'swiper_list': swiper_list})

三、轮播图功能涉及的模型层操作

毫无疑问,插入轮播图功能操作的将是轮播图的数据模型.

四、轮播图功能的前端模板

联系管理员微信tutu19192010,注册账号

上一篇
下一篇
Copyright © 2022 Egon的技术星球 egonlin.com 版权所有 帮助IT小伙伴学到真正的技术