广告位

django模板中自动加载static

您现在的位置是:主页 > 编程 >

2021年9月25日 11:33编程 > 1155人已围观

简介 'builtins': ['django.templatetags.static'] # 模板中自动加载static,不需要写 {% load static %}...

TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': [os.path.join(BASE_DIR, 'templates')]

        ,

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [

                'django.template.context_processors.debug',

                'django.template.context_processors.request',

                'django.contrib.auth.context_processors.auth',

                'django.contrib.messages.context_processors.messages',

            ],

            'builtins': ['django.templatetags.static']  # 模板中自动加载static,不需要写 {% load static %}

        },

    },

]


Tags: django  模板 

广告位
    广告位
    广告位

站点信息

  • 文章统计112篇文章
  • 标签管理标签云
  • 微信公众号:扫描二维码,关注我们