Django Creation Project 3rd: Writing the first template file

Source: Internet
Author: User

1. Django Structure

2, the site blog under the creation of Templates folder, specifically for storing template files

3. Create the index.html file under the Templates folder

#index. html

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>First template file</title></Head><Body>    <H1>Django Create a third project: Write the first template file</H1></Body></HTML>

4. Modify the views.py file

#Create your views here.#Coding:utf-8 fromDjango.httpImportHttpResponse#Import the templates files required to import the library, note that there is no S fromDjango.templateImportLoader,contextdefIndex (Request):#a second project    #return HttpResponse ("Hello,django")    #loader, get a templateT=loader.get_template ("index.html") C=Context ({}) #没有写入数据, simply loading the index.html filereturnHttpResponse (T.render (c))

Django Creation Project 3rd: Writing the first template file

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.