ジャンゴ05ショッピングモールプロジェクトは、(データ・テーブル・axf_mustbuyを設定し、データテーブルaxf_nav、カルーセルバーを設定し、プログラムのデバッグ手法)

1、データテーブルaxf_navを設定します

アプリ/ models.py

from django.db import models


class Main(models.Model):
    img = models.CharField(max_length=255)
    name = models.CharField(max_length=64)
    trackid = models.IntegerField(default=1)

    class meta:
        abstract = True


class MainWheel(Main):
    class Meta:
        db_table = 'axf_wheel'


class MainNav(Main):
    class Meta:
        db_table = 'axf_nav'

移行:

#生成迁移文件:
python manage.py makemigrations
#执行迁移文件:
python manage.py migrate

挿入データ:
ここに画像を挿入説明
ここに画像を挿入説明
ここに画像を挿入説明
ディスプレイ:

ここに画像を挿入説明
CSS

/*底部图标和文字样式*/
footer .home span {
    background: url(/static/img/home_selected.png) no-repeat;
    background-size: 0.513889rem;
}

footer .home dd {
    color: orange;
}

/*顶部轮播*/
#home {
    padding: 1.5rem 0;
    overflow: auto;
    height: 100%;
    width: 100%;
    padding-bottom: 3rem;
    position: fixed;
}

#topSwiper {
    height: 3.95rem;
    width: 10rem;
    overflow: hidden;
}

#topSwiper div a {
    display: inline-block;
    height: 3.95rem;
    width: 10rem;
}

#topSwiper img {
    height: 100%;
    width: 100%;
}

/*顶部导航*/
.topMenu {
    padding-bottom: 0.26rem;

}

.topMenu nav {
    margin: 0.35rem 0 0.26rem;
    background: white;
}

.topMenu nav ul {
    display: flex;
}

.topMenu nav li {
    width: 2.5rem;
    text-align: center;
    font-size: 0.35rem;

}

.topMenu nav li img {
    width: 2.5rem;
}

#swiperMenu {
    width: 100%;
}

表示:
ここに画像を挿入説明
アクセス:
ここに画像を挿入説明

図2は、データテーブルaxf_mustbuyを設定します

テンプレート:
ここに画像を挿入説明
移行:

#生成迁移文件:
python manage.py makemigrations
#执行迁移文件:
python manage.py migrate

データの挿入:
ここに画像を挿入説明
ビュー:
ここに画像を挿入説明
:フロントエンドディスプレイ、home.html
ここに画像を挿入説明
この期間を追加home.css


/*首页必购*/
#swiperMenu {
    width: 100%;
}

#swiperMenu li img {
    width: 100%;
}

home.js(追加、変更を持って、次のように完全なコードです):

$(function () {
    ISpr();
ISprMenu();
})

function ISpr() {
    var swiper = new Swiper("#topSwiper", {
            loop: true,
            autoplay: 3000,
            pagination: '.swiper-pagination'
        }
    );
}
function ISprMenu() {
    var swiper = new Swiper("#swiperMenu", {
           slidesPerView: 3,
        }
    );
}

アクセス:
ここに画像を挿入説明

3、プログラムのデバッグ手法

ここに画像を挿入説明
ジャンゴデバッグツールをインストールします。

pip install django-debug-toolbar

インストールが完了したら

設定中に登録
ここに画像を挿入説明
ここに画像を挿入説明

'debug_toolbar',

'debug_toolbar.middleware.DebugToolbarMiddleware'

INTERNAL_IPS = ('127.0.0.1','localhost')

urls.pyここに画像を挿入説明

from AXF01 import settings
if settings.DEBUG:
    import debug_toolbar

    urlpatterns = [
                      path('__debug__/', include(debug_toolbar.urls)),
                  ] + urlpatterns

アクセス:
ここに画像を挿入説明

楽しいプラグインでのpython:thefuck

参考视频:https://www.bilibili.com/video/av69060979?p=271
2320秒开始
公開された87元の記事 ウォン称賛20 ビュー1635

おすすめ

転載: blog.csdn.net/a__int__/article/details/103445981
おすすめ