在pycharm(企业版)中新建Django工程,注意使用虚拟环境
创建成功后,在pycharm显示的工程目录结构如下:
打开pycharm的终端,进入该工程的目录新建一个django工程
python3管理。py startapp django_web >之前执行成功后,工程目录结构如下:
修改settings.py文件,注册该工程
Django的开发遵循MTV模式(模型、模板、视图),views.py负责执行操作,models.py负责数据处理(如数据库连接),模板目录下存放网页的模板
首先在模板下新建一个index . html文件,并把以下内容替换到该文件中
& lt; !DOCTYPE html> & lt; html lang=癳n”比; & lt; head> & lt;元charset=皍tf - 8”比; & lt; title> blah & lt;链接rel="样式表" type=" text/css " href=" https://www.yisu.com/zixun/new_blah.css " rel=巴獠縩ofollow”比; & lt;/head> & lt; body> & lt; div类="头"比; & lt; img src=" https://www.yisu.com/zixun/images/blah.png "比; & lt; ul类="导航"比; & lt; li> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞Home & lt;/li> & lt; li> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞Site & lt;/li> & lt; li> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞Other & lt;/li> & lt;/ul> & lt;/div> & lt; div类=爸饕谌荨北? & lt; h3> Article & lt; ul类="文章"比; & lt; li> & lt; img src=" https://www.yisu.com/zixun/images/0001.jpg "宽度=" 100 "高度=" 90 "比; & lt; h4> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞blah & lt;/h4> & lt; p>这是一个危险的美味蛋糕。;/p> & lt;/li> & lt; li> & lt; img src=" https://www.yisu.com/zixun/images/0002.jpg "宽度=" 100 "高度=" 90 "比; & lt; h4> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞blah & lt;/h4> & lt; p>它总是taco晚上某个地方! & lt;/p> & lt;/li> & lt; li> & lt; img src=" https://www.yisu.com/zixun/images/0003.jpg "宽度=" 100 "高度=" 90 "比; & lt; h4> & lt; a href=" https://www.yisu.com/zixun/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”祝辞blah用pycharm开发django项目示例代码