Python3.6.3 + Django2.0.1 + Bootstrap3.3.7[2]

Configuration

  • Python 3.6.3
  • Django 2.0.1
  • Bootstrap 3.3.7

  • localhost:8000/static/img/a.jpg

vim my/my/settings.py

Add STATICFILES_DIRS

mkdir my/static
mkdir my/static/img
cp a.jpg my/static/img

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
### Add STATICFILES_DIRS ###
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
  • localhost:8000/bs/bs1
    First page for bootstrap 3.3.7

vim my/bs/urls.py

from django.shortcuts import render

# Create your views here.
from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.bootstrap_title, name="bootstrap_home"),
    ### Add bs1 ###
    url(r'^bs1$', views.bs_bs1, name="bootstrap_bs1"),
]

vim my/bs/views.py

def bs_bs1(request):
    return render(request, "bs/bs1.html")

cp bootstrap & jquery

cp bootstrap-3.3.7-dist my/static/
cp jquery my/static/

vim my/templates/bs/bs1.html

{% load static %}
  <link rel="stylesheet" href="{% static 'bootstrap-3.3.7-dist/css/bootstrap.min.css' %}">
  <script src="{% static 'jquery/jquery-3.2.1.min.js' %}"></script>
  <script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.min.js' %}"></script>
{% load static %}
<!DOCTYPE html>
<html>
<head>
  <title>Hello world! This is Blog! Bootstrap 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="{% static 'bootstrap-3.3.7-dist/css/bootstrap.min.css' %}">
  <script src="{% static 'jquery/jquery-3.2.1.min.js' %}"></script>
  <script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.min.js' %}"></script>

</head>
<body>
<table class="table table-hover">
  <caption>悬停表格布局</caption>
  <thead>
    <tr>
      <th>名称</th>
      <th>城市</th>
      <th>邮编</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Tanmay</td>
      <td>Bangalore</td>
      <td>560001</td>
    </tr>
    <tr>
      <td>Sachin</td>
      <td>Mumbai</td>
      <td>400003</td>
    </tr>
    <tr>
      <td>Uma</td>
      <td>Pune</td>
      <td>411027</td>
    </tr>
  </tbody>
</table> 
</body>
</html>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值