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

Configuration

  • Python 3.6.3
  • Django 2.0.1
  • Bootstrap 3.3.7

  • localhost:8000/admin
django-admin startproject my
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver

  • localhost:8000/bs/bs1
python3 manage.py startapp bs

vim my/my/urls.py

### Add:import url,include ###
from django.conf.urls import url,include
urlpatterns = [
    path('admin/', admin.site.urls),
    ### Add:bs(bootstrap) ###
    url(r'^bs/', include('bs.urls')),
]

vim my/my/settings.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        #'DIRS': [],
        ### Add:templates ###
        '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',
            ],
        },
    },
]

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"),
]

vim my/bs/views.py

# Create your views here.
from django.shortcuts import render

# Create your views here.
def bootstrap_title(request):
    return render(request, "bs/bs_home.html")

vim my/templates/bs_home.html

<!DOCTYPE html>
<html>
<head>
  <title>Hello world! This is Blog! Bootstrap</title>
  <meta charset="utf-8">
</head>
<body>
    <h1>My first page: bs_home.html</h1>
</body>
</html>

[1]: Python3.6.3 + Django2.0.1 + Bootstrap3.3.7[1]
http://mp.blog.csdn.net/mdeditor/index/79127576
[2]: Python3.6.3 + Django2.0.1 + Bootstrap3.3.7[2]
http://mp.blog.csdn.net/mdeditor/index/79128237

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值