zoukankan      html  css  js  c++  java
  • django开发商城(提供初始数据,商城首页及购物车)

    1.爬取数据

    2.json数据转化为sql语句

    3.新建轮播图模型(模型名与sql语句对应表名相同)

    class Wheel(models.Model):
        img=models.CharField(max_length=150)
        name=models.CharField(max_length=20)
        trackid=models.CharField(max_length=20)

    4.终端打开mysql,执行插入语句

    5.在首页进行展示轮播图(home.html)

          <div class="swiper-container" id="topSlider">
            <div class="swiper-wrapper">
                {% for item in sliderList %}
                <div class="swiper-slide">
                    <a href="#"><img src="{{ item.img }}"></a>
                </div>
                {% endfor %}
            </div>
        </div>

    设置轮播(home.js)

    $(document).ready(function () {
        var swiper = new Swiper('#topSlider', {
            direction: 'horizontal',
            loop: true,
            speed: 500,
            autoplay: 2000,
            pagination: {
                el: '.swiper-pagination',
            }
    
        })
    
    })

    6.展示主要商品

    建立模型,在数据库进行插入

    class MainShow(models.Model):
        trackid = models.CharField(max_length=10)
        name = models.CharField(max_length=20)
        img = models.CharField(max_length=100)
        categoryid = models.CharField(max_length=10)
        brandname = models.CharField(max_length=20)
    
        img1 = models.CharField(max_length=100)
        childcid1 = models.CharField(max_length=10)
        productid1 = models.CharField(max_length=10)
        longname1 = models.CharField(max_length=50)
        price1 = models.CharField(max_length=10)
        marketprice1 = models.CharField(max_length=10)
    
        img2 = models.CharField(max_length=100)
        childcid2 = models.CharField(max_length=10)
        productid2 = models.CharField(max_length=10)
        longname2 = models.CharField(max_length=50)
        price2 = models.CharField(max_length=10)
        marketprice2 = models.CharField(max_length=10)
    
        img3 = models.CharField(max_length=100)
        childcid3 = models.CharField(max_length=10)
        productid3 = models.CharField(max_length=10)
        longname3 = models.CharField(max_length=50)
        price3 = models.CharField(max_length=10)
        marketprice3 = models.CharField(max_length=10)

    进行展示

            {#  mainShow #}
            <section class="mainInfo">
                {% for item in mainShowList %}
                <section>
                    <h3>
                        {{ item.name }}
                        <a href="#">更多&gt;</a>
                        <span></span>
                    </h3>
                    <div>
                        <a href="#"><img src="{{ item.img }}">
                        </a>
                    </div>
                    <ul>
                        <li><a href="">
                            <img src="{{ item.img1}}" alt="">
                            <span class="">
                            {{ item.longname1 }}
                        </span>
                        <span>
                            ¥{{ item.price1 }}<s>¥{{ item.marketprice1 }}</s>
                        </span>
                        </a></li>
                         <li><a href="">
                            <img src="{{ item.img2}}" alt="">
                            <span class="description">
                            {{ item.longname2 }}
                        </span>
                        <span>
                            ¥{{ item.price2 }}<s>¥{{ item.marketprice2 }}</s>
                        </span>
                        </a></li>
                         <li><a href="">
                            <img src="{{ item.img3}}" alt="">
                            <span class="description">
                            {{ item.longname3 }}
                        </span>
                        <span>
                            ¥{{ item.price3 }}<s>¥{{ item.marketprice3 }}</s>
                        </span>
                        </a></li>
                    </ul>
                </section>
                {% endfor %}
            </section>
  • 相关阅读:
    Oracle根据【日期】组,其他条件根据PIVOT行转列。使每个日期条件关联的其他数据只有一行。
    ORACLE数据库,数据量大,转移数据到备份表语句
    C#解析"a=1&b=2&c=3"字符串,微信支付返回字符串,替换<br>为&
    dataTable的数据,调试的时候点放大镜就看到了啊啊啊!
    Debug和Release 老程序啊 调试之前 区分一下啊
    FastReport.NET
    grpc 实现微服务生态笔记
    金木水火土
    shell 指令分析nginx 日志qps
    idea中使用tomcat 方式启动spring boot项目
  • 原文地址:https://www.cnblogs.com/hhy-love-python/p/8555384.html
Copyright © 2011-2022 走看看