DjangoEnvironment ConstructionI. Version selection
The Django 1.5.x supports Python 2.6.5 python 2.7, Python 3.2 and 3.3.
Django 1.6.x supports Python 2.6.X, 2.7.X, 3.2.X and 3.3.X
The Django 1.7.x supports Python 2.7, 3.2, 3.3, and 3.4 (note: Python 2.6 is not supported)
The Django 1.8.x supports Python 2.7, 3.2, 3.3, 3.4, and 3.5. (Long-term support version of LTS)
The Django 1.9.x supports Python 2.7, 3.4, and 3.5. 3.3 is not supported.
The Django 1.10.x supports Python 2.7, 3.4, and 3.5.
The next long-term support version of Django 1.11.x will be released in April 2017
More details can be found here, in general, the choice of long-term support version is better.
The problem with the latest version is that some of the third-party plug-ins that may be used are not updated in a timely manner and do not use these three-party packages properly.
If you are learning, you can choose the current Django 1.8.x to do, encounter problems and easy to find the answer.
Of course, if you need a new version of the feature can also use the new version, after all Django 1.9 Admin interface is still more beautiful
two. Install Django
Note: Any of the following methods can be installed without having to try each one.
It is also recommended to install the Bpython yourself, which will be a lot more fun to use. Enter the terminal when the input Bpython can be prompted. Of course, you can also choose to use Ipython
2.0 about the installation of Bpython
$sudo apt-Get
2.1. Use Pip to install
2.1.1 Need to install PIP first
(1). Ubuntu:
sudo apt-get Install Python-pip
(2). Fedora:
Yum Install Python-pip
(3). Linux, Mac OSX, Windows are available under get-pip.py to install pip:https://pip.pypa.io/en/latest/installing.html
or download directly: get-pip.py then run the Python get-pip.py on the terminal to install PIP.
Note: You can also download the PIP source package and run the python setup.py Install
2.1.2 using PIP to install Django
(sudo) pip install Django= =1.8. or pip install django==1.10. 3
If you want to upgrade PIP you can use:
(sudo) pip install--upgrade pip
Windows users do not add sudo, and if the hint ' python ' is not an internal or external command, it is not a program or batch file that can be run.
That means that your Python is not installed, or the environment variable is not configured correctly, the simplest way is to install the new version of the Python 2.7.9, which integrates the PIP, the installation to tick the environment variable this one
See also: Python environment setup
2.2. Download the source installation
https://www.djangoproject.com/download/
If it is a source package, such as django-1.8.16.tar.gz
2.2.1 Linux or Mac
TAR-XVF django-1.8. - . TAR.GZCD Django-1.8. - (sudo) python setup.py install
2.2.2 Under Windows
Unzip directly with the decompression software, and then to the command line (xp/win7 Click to start , enter cmd in the input box below, WIN8 at the beginning right click, select command Line)
For example, under the D:\django-1.8.16\ folder
CD D:CD Django-1.8. - python setup.py Install
What the? Tip ' python ' is not an internal or external command, or a program or batch file that can be run.
That means your Python is not installed, or the path is not configured correctly, see: Python Environment Setup
2.3. Linux installation with a self-source (not recommended)
2.3.1 Install Django under Ubuntu
sudo apt-get Install Python-django-y
2.3.2 Fedora under Installation with Yum
Yum install python-django
Note: the Django generic version that comes with the source installation is older, and the latest version can be installed with PIP.
Three. Check if the installation is successful
Enter Python on the terminal, click Enter to make the Python environment
>>> Import Django>>> Django. VERSION (18'final'0)>> > >>> django.get_version ()'1.8.16'
If you see the version number after running, it proves the installation is successful, please comment!
Four. Build multiple non-disruptive development environments (optional)
We sometimes find that there are multiple projects on a computer, one that relies on Django 1.8 and another older project that uses Django 1.5.
We need a tool that relies on package management to handle different environments.
If you do not want to build this environment, only want to use a certain version of Django can also, but recommended to learn this content!
4.1 Environment Construction
Development uses VIRTUALENV to manage multiple development environments, Virtualenvwrapper makes virtualenv more usable
# Install: (sudo) pip install virtualenv Virtualenvwrapper
Linux/mac OSX below:
Modify ~/.bash_profile or other environment variable related files (such as. bashrc or. ZSHRC after ZSH), add the following statement
export Workon_home= $HOME/. Virtualenvsexport project_home= $HOME//usr/local/bin/ virtualenvwrapper.sh
Make it effective immediately (or you can restart the terminal to make it effective):
~/.bash_profile
Under Windows:
pip install virtualenvwrapper-win
The "optional" Windows default virtual environment is placed under the user name in the Envs, with the desktop, My Documents, downloads and other folders in one piece. Change method: Computer, properties, advanced system settings, environment variables, add Workon_home, (Windows 10 environment variable settings):
4.2 How to use:
Mkvirtualenv ZQXT: Creating a Running environment ZQXT
Workon ZQXT: Working in a ZQXT environment or switching from another environment to a ZQXT environment
Deactivate : Exiting the terminal environment
Other:
rmvirtualenv ENV: Delete Running environment env
mkproject Mic: Create MIC Project and run environment mic
mktmpenv: Creating a temporary runtime environment
lsvirtualenv: List the available run environments
lssitepackages: Lists the packages that are installed in the current environment
The created environment is independent, non-intrusive, and requires no sudo permission to manage the package using PIP.
Python-django Framework Learning Notes-Lesson two: Django Build