First Django Program:
1. Install python2.x, it is recommended to install 2.6 or 2.7 download address www.python.org
Configure environment variables My Computer-> Properties-> Advanced-> Environment variables-> System variables
Increase Python_home C:\Python27
Modify path to join%python_home%
2. Install Django Download Address https://www.djangoproject.com/
Currently 1.3.1, unzip the downloaded file and put it where you want it to be
Start-run-cmd switch to the location where you unzipped the file
Executive: setup.py Install
After installation, add the%python_home%\scripts to the path, because the django-admin.py below the path will use
3. New project:
Start-run-cmd switch to workspace
Build Project
django-admin.py Startproject Hello
Get the Hello folder under four files
__init__.py says it's a python bag with no content inside.
MANAGE.PY provides a simplistic django-admin.py command.
settings.py configuration file
urls.py URL Mapping file
You can start the service at this time
manage.py Runserver
Access to: Http://localhost:8000/
The page is as follows:
4. Edit the project with Pydev to achieve the first HelloWorld
Pydev plugin is installed and configured to open eclipse
File–new–pydev Project
Enter project name
Cancel the use Default and choose the directory you created for the third step
To add a source code folder:
Click Item, right button, properties
Pydev-pythonpath Source floders tab ADD Source Floder
Join the current project folder
Create a first.py file under SRC
The contents are as follows
Fromdjango.http Importhttpresponse
defHello(Request):
Returnhttpresponse ("Hello world! A-Django ")
Modify urls.py, increase
(R ' ^first$ ', ' First.hello '),
Select manage.py-Right –run as–run configurations
Add run parameter (x) = Arguments tab
Runserver–noreload
After that, you can start the service directly in eclipse
Select manage.py, right-click Python Run
Access:
Http://localhost:8000/first