Django Notes--eclipse+pydev First Django example HelloWorld

Source: Internet
Author: User
Tags install django

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.