Python + Django Note 1 *

Source: Internet
Author: User

Enter the Python environment and enter:

1 >>> pip install Django

Wait for the installation to complete before you can use Django.

Version used in this article: Python 2.7.9,django 1.8.0

Build the project:

In command mode, enter:

A project named MySite is created in the current directory.

Django comes with a development server dedicated to testing. is still in the command environment, enter MySite, enter:

> Python manage.py runserver

Now enter the address in the browser: 127.0.0.1:8000 to the test page.

To add an app:

Under \mysite, enter:

> Python manage.py startapp Hello

An app called Hello will be created. But you need a little bit of setup to use it.

First enter \mysite\mysite, in the settings.py in the Installed_app add:

' Hello ',

Add a mapping in urls.py:

URL (r'^hello/$'hello.views.index'Index  '),

Enter \mysite\hello, add in views.py:

 from Import HttpResponse def Index (req):     return HttpResponse ('')

When you are finished, you can open your browser and see the results at 127.0.0.1:8000/hello

Python + Django Note 1 *

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.