首先连上网,创建项目:django-admin startproject proj1或者在pycharm新建项目pro1
以下都是在proj1项目文件夹根目录下进行
a.在templates文件夹下面新建index.html, 打开如下网址:
https://v4.bootcss.com/
点击快速入门,进入简介以后,拉下来,到“入门模版”,拷贝入门模版中的代码到index.html里面。
b.简介页面左侧点击“组件”,进入组件页面,在组件中选择一个拷贝进index.html的中(可以是按钮或者其他组件)
a.打开命令行工具(系统自带或者pycharm的Terminal)
b.django-admin startapp app1
或者python manage.py startapp app1
c.在proj1/settings.py里面INSTALLED_APPS里注册这个应用app1
a.修改app1/views.py,增加视图函数
def showIndex(request):
return render(request, ‘index.html’)
b.修改proj1/urls.py,引入视图函数:
from app1.views import showIndex
在urlpatterns中加入一行:
path(’’, showIndex)
4.点击右上角绿色小三角运行项目(或者用firefox打开127.0.0.1:8000)