模板中加载静态文件
settings.py的APP内需安装front
front app下创建static/front,将logo.jpg放置
first.html
{% extends ‘base.html’ %} #继承base.html
{% block content %}
{{ block.super }}
这是首页的代码
{% endblock %}
def welcome(request):
return render(request,‘first.html’)
显示如下
加载静态文件,需加在html行首
{% load static %}
若想变为内置标签,在settings.py的OPTIONS内添加如下
‘builtins’:[‘django.templatetags.static’]