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