Django foundation necessary three-piece **:
-
HttpResponse inside pass a string parameter and returns to the browser.
from django.shortcuts Import the HttpResponse DEF index (Request): # business logic code return the HttpResponse ( " the OK " )
-
In addition to render request parameter also accepts a template file to be rendered and saved a data dictionary specific parameters.
The data filled in the template file, and finally return the result to the browser.
from django.shortcuts Import the render DEF index (Request): # business logic code return the render (Request, " index.html " , { " name " : " Alex " , " Hobby " : [ " hot head " , " bars " ]})
-
redirect accept a URL parameter that indicates a jump to the specified URL.
from django.shortcuts Import the redirect DEF index (Request): # business logic code return the redirect ( " / Home / " )