Django installation
Before installing Django, the system needs to have a Python development environment installed. Next, let’s take a closer look at the installation of Django under different systems.
Installing Django under Window
If you have not installed the Python environment, you need to download the Python installation package first.
1. Python download address: https://www.python.org/downloads/
2. Django download address: https://www.djangoproject.com/download/
Note: Currently Django 1.6.x or above is fully compatible with Python 3.x.
Python installation (already installed can be skipped)
To install Python, you only need to download the python-x.x.x.msi file, and then keep clicking the "Next" button.
![1476768440564493.png install1.png](http://img.php.cn/upload/image/550/434/922/1476768440564493.png)
After the installation is complete, you need to set the Python environment variables. Right-click Computer->Properties->Advanced->Environment Variables->Modify the system variable path and add the Python installation address. The example in this article uses C:\Python33. You need to install it according to your actual situation.
![1476768453148426.png 1025.png](http://img.php.cn/upload/image/377/473/765/1476768453148426.png)
Django installation
![1476768481930966.jpg install3.jpg](http://img.php.cn/upload/image/565/239/241/1476768481930966.jpg)
#Then configure the environment variables and add these directories to the system environment variables: C:/Python33/Lib/site-packages/django;C:/Python33/Scripts. After the addition is completed, you can use Django's django-admin.py command to create a new project.
![1476768503934211.jpg install4.jpg](http://img.php.cn/upload/image/626/215/797/1476768503934211.jpg)
Check whether the installation is successful
Enter the following command to check:
python import django django.get_version()
![1476768523587180.jpg install5.jpg](http://img.php.cn/upload/image/980/100/636/1476768523587180.jpg)
If the Django version number is output, it means the installation is correct.
Installing Django on Linux
yum installation method
The following installation is installed in Centos Linux environment. If your Linux system is ubuntu, please use apt-get Order.
The Linux environment already supports Python by default. You can enter the Python command in the terminal to check whether it is installed.
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. >>>
Install setuptools
Command:
yum install setuptools
After completion, you can use the easy_install command to install django
easy_install django
After that, we enter the following code in the python interpreter:
[root@solar 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) >>>
We can see that the version number of Django is output, indicating that the installation is successful.
pip command installation method
pip install Django
Source code installation method
Download the source code package: https://www.djangoproject.com/download/
Enter the following Command and install:
tar xzvf Django-X.Y.tar.gz # 解压下载包 cd Django-X.Y # 进入 Django 目录 python setup.py install # 执行安装命令
After successful installation, Django is located in the site-packages directory of the Python installation directory.
Installation under Mac
Download
Download the latest stable version from here: DJango-1.x.y.tar.gz, download from the list on the right side of the page, as shown below:![1476768567608201.jpg 1038.jpg](http://img.php.cn/upload/image/250/545/781/1476768567608201.jpg)
$ tar zxvf Django-1.x.y.tar.gz
You can also download it from Download the latest version on Github, address: https://github.com/django/django:
git clone https://github.com/django/django.git
Installation
Enter the decompressed directory:
cd Django-1.x.y sudo python setup.py install
After successful installation The following information will be output:
…… Processing dependencies for Django==1.x.y Finished processing dependencies for Django==1.x.y
Then enter our site directory and create a Django project:
$ django-admin.py startproject testdj
Start the service:
cd testdj # 切换到我们创建的项目 $ python manage.py runserver …… Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
The above information indicates that the project has been started, access address is http://127.0.0.1:8000/.