官方文档地址:https://django-bootstrap.readthedocs.io/en/latest/installation.html
要注意的是,如果引用了base.html,那么同时也会继承base里面的
{% block bootstrap4_content %},如果想使用bootstrap4_content 的话。
css等就不用重新load了,直接再base中引用就ok。
<!-- jobs/templates/base.html-->
{% load bootstrap4 %}
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}
{% bootstrap_messages %}
<h1 style="margin:auto; width:50%"> 小叮当的主页啦 </h1>
<p></p>
{% block header %}
<a href="/" style="text-decoration: none; color:#007bff">首页</a>
<a href="/joblist" style="text-decoration: none; color:#007bff">职位列表</a>
{% if user.is_authenticated %}
<a href="/accounts/logout" style="text-decoration: none; color:#007bff">退出</a>
{% else %}
<a href="/accounts/login" style="text-decoration: none; color:#007bff">登录</a>
{% endif %}
{% if user.is_authenticated %}
<p>欢迎 {{user.username}}</p>
{% else %}
<p>欢迎游客,请去登录哦!</p>
{% endif %}
{% endblock %}
<hr>
{% block bootstrap4_content %}
{% endblock %}
{% extends 'base.html'%}
{% load bootstrap4 %}
{% block bootstrap4_content %}
<h2>提交简历</h2>
<form method="post" class="form" style="width:300px; margin-left:5px">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-primary">提交</button>
{% endbuttons %}
</form>
{% endblock %}