Before installing Django, the system needs to have installed Python development environment. Next we look at the specific installation under different systems of Django.
Django installation under Window
If you have not installed Python Python environment you need to download the installation package.
1, Python Download: https://www.python.org/downloads/
2, Django Download: https://www.djangoproject.com/download/
Note: Currently, Django 1.6.x or higher already fully compatible with Python 3.x.
Python installation (installed skippable)
You only need to install Python Download python-xxxmsi file and has been click "Next" button.
After installation you need to set the Python environment variable. Right-click Computer -> Properties -> Advanced -> Environment Variables -> Edit System Variables path, add Python installation address, using the examples herein is C: \ Python33, you need to install based on your actual situation.
Django installationDownload Django archive, extract and install directory and Python in the same root directory, enter the Django directory and execute python setup.py install, and then start the installation, it will be installed to Django Python's Lib under site-packages.
Then configure the environment variables, these add several directories to the system environment variable: C: / Python33 / Lib / site-packages / django; C: / Python33 / Scripts. After the addition is complete you can use Django's django-admin.py command the new construction.
Check whether the installation was successful
Enter the following command to check:
python import django django.get_version()
If the output of the version number Django install correctly.
Install Django on Linux
yum install method
The following installation located Centos Linux environment installed, if your Linux system is ubuntu use the apt-get command.
By default, the Linux environment has supported Python. You can enter Python commands in a terminal to see if already 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. >>>
yum install setuptools
Once done, you can use the command to install easy_install django
Then 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 the output of Django version number, indicating that the installation was successful.
pip command installation method
pip install Django
Download Source Package: https://www.djangoproject.com/download/
Enter the following command to install:
tar xzvf Django-X.Y.tar.gz # 解压下载包 cd Django-X.Y # 进入 Django 目录 python setup.py install # 执行安装命令
After a successful installation located in the Django Python installation directory site-packages directory.
downloadFrom here to download the latest stable version: DJango-1.xytar.gz, the right side of the page to download the list, as shown below: Remember that the latest official version, oh, where xy is the version number. You download the file into the folder directory, execute the following command: (By default Mac / Users / xxx / Downloads, xxx is your user name)
$ tar zxvf Django-1.x.y.tar.gz
You can also download the latest version from Github, address: https://github.com/django/django :
git clone https://github.com/django/django.git
Unpacked into the directory:
cd Django-1.x.y sudo python setup.py install
After a successful installation will output the following information:
…… Processing dependencies for Django==1.x.y Finished processing dependencies for Django==1.x.y
Re-enter our site directory, 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 shows that the project has been started, visit the address http://127.0.0.1:8000/.