Third, Python Django template

Source: Internet
Author: User

Python Django Template


Link up on an article


First, create a template file


# Cat Blog/template/index.html

<?xml version= "1.0" encoding= "UTF-8"?>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.0.5 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>

<title>csvt</title>

<body>

</body>


Ii. Publishing template files to a view method

(1) The first method:

# Cat blog/views.py

From django.http import HttpResponse

From django.template import Loader,context

def index (req):

t = loader.get_template (' index.html ')

c = Context ({})

Return HttpResponse (T.render (c))



(2) The second method:

# Cat blog/views.py

From django.shortcuts import Render_to_response

def index (req):

Return Render_to_response (' index.html ', {})


The same results can be obtained by accessing http://192.168.116.129/blog/index/through the browser


This article is from "Meteor Yu" blog, please be sure to keep this source http://8789878.blog.51cto.com/8779878/1850739

Third, Python Django template

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.