Django学习1---安装 Django

📅 2026/7/28 20:11:19
Django学习1---安装 Django
Window 下安装 Django如果你还未安装Python环境需要先下载Python安装包。1、Python 下载地址https://www.python.org/downloads/2、Django 下载地址https://www.djangoproject.com/download/注意目前 Django 1.6.x 以上版本已经完全兼容 Python 3.x。Linux 上安装 Djangoyum 安装方法以下安装位于 Centos Linux 环境下安装如果是你的 Linux 系统是 ubuntu 请使用 apt-get 命令。默认情况下 Linux 环境已经支持了Python。你可以在终端输入Python命令来查看是否已经安装。Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type help, copyright, credits or license for more information. 安装 setuptools命令yum install python-setuptools完成之后就可以使用 easy_install 命令安装 djangoeasy_install django之后我们在python解释器输入以下代码[rootsolar django]# python Python 2.7.3 (default, May 15 2014, 14:49:08) [GCC 4.8.0] on linux2 Type help, copyright, credits or license for more information. import django django.VERSION (1, 6, 5, final, 0) 我们可以看到输出了Django的版本号说明安装成功。pip 命令安装方法如果你还未安装 pip 工具可查看Python pip 安装与使用。pip install Django如果 pip 1.4安装方法如下pip install https://www.djangoproject.com/download/1.11a1/tarball/源码安装方法下载源码包https://www.djangoproject.com/download/输入以下命令并安装tar xzvf Django-X.Y.tar.gz # 解压下载包 cd Django-X.Y # 进入 Django 目录 python setup.py install # 执行安装命令安装成功后 Django 位于 Python 安装目录的 site-packages 目录下。进入我们的站点目录创建 Django 项目$ django-admin.py startproject testdj启动服务cd testdj # 切换到我们创建的项目 $ python manage.py runserver …… Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.以上信息说明项目已启动访问地址为http://127.0.0.1:8000/。