ジャンゴ - テンプレートのCSSコール

Djangoのバージョン:2.1




A:設定ファイルのsettings.py

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            
STATIC_URL="/static_xxx/"
            
STATICFILES_DIRS=(
    os.path.join(BASE_DIR,"static"),
)

II:テンプレート・コール(両方の方法は、settings.pyファイルを構成する必要があります)

        1.テンプレート言語
            <HEAD>タグ内の1>ステートメント{%負荷staticfiles%}
            2>リンクCSS

 <link rel="stylesheet" type="text/css" href="{% static_xxx "abc.css" %}">


        2.仮想パス
            1>ロードstaticfilesを宣言しない%%} {
            2>リンクCSS

 <link rel="stylesheet" type="text/css" href="/static_xxx/abc.css">

 

 

おすすめ

転載: blog.csdn.net/qq_42292831/article/details/93869926