Django Note--eclipse+pydev First Django example HelloWorld

Source: Internet
Author: User

This post was reproduced from: http://blog.csdn.net/wklken/article/details/7234157

The first Django program:

1. Install the python2.x, it is recommended to install 2.6 or 2.7 www.Python.org

Configure environment variables, properties--environment variables--System variables

Add Python_home C:\Python27

Modify path Join%python_home%

2. Installing the Django https://www.djangoproject.com/

Currently 1.3.1, unzip the downloaded files and place them where you want them.

Start-run-cmd switch to the location where the extracted files are placed

Execution: setup.py Install

Add%python_home%\scripts to path after installation, because the django-admin.py below the path will be used after

3. New project:

Start-run-cmd switch to work space

Build Project

django-admin.py Startproject Hello

Get a Hello folder under four files

__init__.py says this is a Python package with no content
Manage.py provides a simplified django-admin.py command
settings.py configuration file
urls.py URL Mapping file

The service can now be started

manage.py Runserver

Access to: Http://localhost:8000/

The page is as follows:

4. Edit the project with Pydev to achieve the first HelloWorld

After the Pydev plugin is installed and configured, turn on eclipse

File–new–pydev Project

Enter project name

Cancel the use Default and choose the directory you created for the third step.

Add Source code folder:

Click on Project, 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! First Django")

Modify urls.py, add

(R' ^first$ ', ' First.hello '),

Select manage.py-Right-–run as–run configurations

Join 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

Django Note--eclipse+pydev First Django example HelloWorld

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.