Django
Django简介
Django是一个Web应用框架(python写的),它使得搭建一个好的Web应用更加方便。Django采用MVC软件设计模式(M-Model, V-View, C-Control)
Django与Python对应版本
Django版本 | Python版本 |
---|---|
1.8 | 2.7, 3.2 , 3.3, 3.4, 3.5 |
1.9, 1.10 | 2.7, 3.4, 3.5 |
1.11 | 2.7, 3.4, 3.5, 3.6 |
2.0 | 3.4, 3.5, 3.6, 3.7 |
2.1,2.2 | 3.5, 3.6, 3.7 |
Django安装
安装Django之前需要先安装Python
一、Windows平台
1.安装python
python下载地址:https://www.python.org/downloads/
根据提示安装,安装成功后需要将python加入环境变量
2.安装Django
命令行输入如下命令:
pip install django
使用pip进行安装,安装路径在python安装目录下:python\Lib\site-packages\django
检查安装成功:
python -m django --version
3.安装过程中出现的问题
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
django from https://files.pythonhosted.org/packages/b2/79/df0ffea7bf1e02c073c2633702c90f4384645c40a1dd09a308e02ef0c817/Django-2.2.6-py3-none-any.whl#sha256=4025317ca01f75fc79250ff7262a06d8ba97cd4f82e93394b2a0a6a4a925caeb:
Expected sha256 4025317ca01f75fc79250ff7262a06d8ba97cd4f82e93394b2a0a6a4a925caeb
Got e799bb0caf17f349da0b10217846dd3183805291d4773643778c0c324dec28e7
这是网速不太好,可以尝试重新下载,或者直接下载django至python安装目录下,执行
python setup.py install
二、Linux
这里仅介绍Ubuntu的情况,由于Ubuntu上自带python2.7所以可以不另外安装python,当然也可以升级成python3。那就直接看看在Ubuntu下面的安装命令
sudo apt-get install python-django -y
三、Mac
下载地址:https://www.djangoproject.com/download/
下载完成后,进入下载目录进行解压并安装
tar zxvf Django-2.2.6.tar.gz
cd Django-2.2.6
sudo python setup.py install