The limitations and concepts of Django DTL template system

Source: Internet
Author: User
Tags require

The limitations and concepts of the Django DTL template system.
The following is from the Django 1.8 LTS Full Solution

Now that you've got a general idea of Django Template Language (DTL), maybe it's time to explain the design behind it. The first thing to know
Tao, DTL's limitations are intentional.
Django originated in the online news site, characterized by large capacity, frequent changes. The first person to design Django had a very clear idea of DTL.
Default.
Today, these ideas remain at the heart of Django. They are:

1. Performance and logic separation
2. Avoid repetition
3. Decoupling from HTML
4. XML
is not good. 5. No design capability required
6. Transparent processing space
7. Do not re-create a programming language
8. Ensure safety and security
9. Expandable

The points below are described below. 1. Representation and logical separation

The templating system is used to control the performance and its associated logic, and that's all. Features beyond this basic goal should not be supported. 2. Avoid duplication

Most dynamic sites use some kind of general-purpose design, such as common headers, footers, navigation bars, and so on. Django Template System
The system should provide a convenient way to store these elements in one place, reducing the duplication of code. This is behind template inheritance.
Idea. 3. Decoupling from HTML

The template system should not only output HTML, but also be able to generate other text-based formats (that is, plain text). 4. XML should not be used as a template language

If you use the XML engine to parse the template, you may introduce a large number of human errors when editing the template, and the processing template has a lot of extra consumption. 5. No design capability required

The template system should not have to be written out in a WYSIWYG editor, such as Dreamweaver. There are too many limitations, syntax is not
Flexible enough.
Django's goal is for template writers to edit HTML directly. 6. Transparent processing space

The template system should not handle spaces specially. Spaces in the template are spaces that appear as text. Not in the Template tab
Spaces should be displayed. 7. Do not re-create a programming language

The template system must not allow:
-Assigning values to variables
-Write Advanced logic
That is, you cannot re-create a programming language. The goal of the templating system is to provide the right amount of programming functionality, such as branching and looping, enough to make a table
Now the relevant judgment is OK.
The Django template system knows that templates are most often written by designers, not programmers, and therefore do not require Python knowledge. 8. Safety Assurance

The template system should disable commands that contain malicious code, such as deleting database records, by default. This is the template system is not allowed to use arbitrary
Another reason for Python code. 9. Expandable

The templating system should recognize that advanced template writers might want to extend functionality. This is the rationale behind the custom template tags and filters
Read.

I've used a lot of different templating systems over the years, and this design is really what I like. DTL and its design approach are one of the main advantages of the Django framework.
in a tense working rhythm, designers and programmers actively communicate and strive to complete their work by the deadline, when Django does not act as a roadblock
Tiger, allowing teams to focus on what they are good at.
Once you realize this in practice, you will soon understand why Django is a "framework for fast-paced perfectionists."
Although this is true, Django is flexible and does not require you to use DTL. Like other components of the WEB application, the template syntax is
highly subjective and the programmer has a different view of it. There are dozens of types of open-source template languages in a Python language alone.
Each occurrence of a new template language means that the existing template language does not meet the needs of the developer.
Django strives to be a full-stack web framework, providing a complete set of components to improve the productivity of web developers, so most of the time it's easier to use DTL, but that's not strictly a requirement.

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.