Install the Python installation tool Pip and check to see if Django has been installed before.
sudo apt-get install Python-pip
2. Install a virtual Python environment that does not affect the current Python environment.
sudo apt-get install python-virtualenvmkdir ~/django #创建一个用于工作的python的独立目录 (name any) virtualenv env #运行命令virtualenv Env creates an Pyhton standalone environment called ENV (name arbitrary), and this environment and native Python environment do not affect each other. SOURCE Env/bin/activate #启用env环境. Pip install-i http://mirrors.aliyuncs.com/pypi/simple django==1.4 #安装1.4 version of Django
3. Check the Django Installation
Enter the python environment >>>import Django>>>django. VERSION
Iv. Creating a Project
Django Project is a Django example that includes a set of settings, such as database settings, Django-specific options, and some configuration of your program. If you use Django for the first time, you need to do some initialization work.
Create a new working directory:
mkdir ~/work
Go to the directory you just created
django-admin.py startproject mysite #这条命令会在当前目录下创建一个 mysite subdirectory
Tree ~/work #观察work目录的结构
Five. Run the development server
CD Mysitepython manage.py Runserver This way, you have a listening 8000 port on your computer and only accept servers that are locally connected from your own computer. The server is now available with a browser to access Http://127.0.0.1:8000/
Python manage.py runserver 8080 #可以修改端口.
This article is from the "North Son" blog, please be sure to keep this source http://itbullet.blog.51cto.com/6681459/1878586
Django Learning 1-django Installation