Build a Django environment and build a django Environment

Source: Internet
Author: User

Build a Django environment and build a django Environment

 

Install Python 2.7.10

Download unzip Django Django-1.9.2.tar.gz

Cmd cd to the extract directory (***)

Python setup. py install

 

 

Check whether the installation is successful

 

Environment Variable

Path

C: \ Python27 \ Lib \ site-packages \ Django-1.9.2-py2.7.egg \ django \ bin;

C: \ Python27 \ Scripts

 

Create a project

Django-admin.py startproject mysite

Dir/B View

Start the server

Cd to mysite first

Manage. py runserver

 

Open web

127.0.0.1: 8000

View port usage netstat-ano

 

Kill Process

Manage. py runserver 8080 ~~~ Hemp eggs

Http://www.oschina.net/question/234345_54799

Http://www.ibm.com/developerworks/cn/linux/l-django/

 

Hello World

The page content is generated by view function. The URL is defined in URLconf.

 

1. Create a Project

Django-admin.py startproject mysite

2. Create an APP in the manage. py directory.

manage.py startapp polls

3. Create a View Function

Path: polls/view. py

from django.shortcuts import render# Create your views here.from django.http import HttpResponsedef index(request):    return HttpResponse("HelloWorld")

4. Create URLconf

Polls/urls. py

from django.conf.urls import urlfrom . import viewsurlpatterns=[    url(r'^$',views.index,name='index'),]

Link to root URLconf

from django.conf.urls import include,urlfrom django.contrib import adminurlpatterns = [    url(r'^polls/',include('polls.urls')),    url(r'^admin/', admin.site.urls),]

 

To call the view, we need to map it to a URL

 

Result:

 

Problems:

 

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.