Django Learning-2 templates

Source: Internet
Author: User

How to use the Render template method to display content.

1. Create a project Dream

django-admin.py Startproject Dream

CD dream and create an app

Python manage.py Startapp Learn

2, add the created application-learn to settings. In Installed_apps

INSTALLED_APPS  = (      ‘django.contrib.admin‘ ,      ‘django.contrib.auth‘ ,      ‘django.contrib.contenttypes‘ ,      ‘django.contrib.sessions‘ ,      ‘django.contrib.messages‘ ,      ‘django.contrib.staticfiles‘ ,      ‘learn‘ , )3. Open learn/views.py Write a view of the home page from django.shortcuts import render def home (Request): Return render (Request, ' home.htm L ') 4, Focus: Create a templates directory under the Learn directory and create a home.html file under it default configuration, Django template will automatically find files in the Templates folder under the app dream
├── learn │   ├── __init__.py │   ├── admin.py │   ├── migrations │   │   └── __init__.py │   ├── models.py │   ├── templates │   │   └── home.html │   ├── tests.py │   └── views.py ├── manage.py └── dream
     ├── __init__.py      ├── settings.py      ├── urls.py      └── wsgi.py 4 directories, 12 files5, now is to write the corresponding content in the home.html <! Doctype>

Django Learning-2 templates

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.