python学习笔记项目_python第三方库之Django学习笔记一
1、安裝Django
pip install Django
2、版本號查詢
python -m django --version
3、創(chuàng)建項目
切換到你想創(chuàng)建項目的目錄,執(zhí)行命令:django-admin startproject dayang
命令執(zhí)行成功后生成項目,目錄結構如下:
外面的一層目錄dayng 是項目的容器,注意不能命名為Django
manage.py: 一個實用的命令行工具,可讓你以各種方式與該 Django 項目進行交互。
The inner dayang/ directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. dayang.urls).
dayang/__init__.py: 一個空文件,告訴 Python 該目錄是一個 Python 包。
dayang/settings.py: Django 項目的配置文件.
dayang/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site.
dayang/wsgi.py: 一個 WSGI 兼容的 Web 服務器的入口,以便運行你的項目。
4、運行django項目
切換到目錄dayang執(zhí)行命令:manage.py runserver
運行成功!
小貼士:修改端口命令【manage.py runserver 8080】
5、創(chuàng)建app
切換到manage.py同級目錄,執(zhí)行命令:manage.py startapp polls
現(xiàn)在的結構目錄如下:
6、編寫你的第一個視圖
To call the view, we need to map it to a URL - and for this we need a URLconf.
新建文件urls.py
The next step is to point the root URLconf at the polls.urls module.
運行命令:manager.py runserver
查看運行結果:
總結
以上是生活随笔為你收集整理的python学习笔记项目_python第三方库之Django学习笔记一的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一篇文章轻松搞定SpringSecuri
- 下一篇: 苹果电脑python制作圣诞树的教程