This article mainly introduces how to use Django templates to work with string translation. Django is the most popular Python development framework. if you need them, refer to the Django template to use two template tags, the syntax format is somewhat different from that of Python code. To enable the template to access
Open the Current_datetime view. Here's what it says:
From django.http import httpresponseimport datetimedef current_datetime (Request): Now = Datetime.datetime.now () html = "It is now%s."% now return HttpResponse (HTML)
Let's use the Django templating system to modify the view. As a first step, you might have thought of making the following changes:
From django.template import template, Contextfrom django.http import httpresponseimport datetimed
; P> inputtype= "Submit"value= "Submit"/> form>Body>HTML>test.htmldef Test (Request): if Request.method = = "GET": Return render (Request, ' Te St.html ') elif Request.method = = "POST": # text V = Request. Post.get (' pwd ') # Gets the input input box with the value print (v) # Radio V0 = Request. Post.get (' Gender ') # gets radio's value print (v0) # checkbox v1 = Request. Post.getlist (' favor ') # Gets the checkbox multiple selection in the case of value print (v1) # Select
To reduce the redundant code of the template loading call process and the template itself, Django provides a handy and powerful API for loading templates from diskTo use this template to load the API, you first have to tell the framework where to save the template.The saved file of the set is the settings.pymentioned in the previous section when we described the root_urlconf configuration.Installed_apps = (
1 templates:What is a template?html+ template Syntax Templates include variables that are replaced by values when they are used, and tags that control template logic.2 template syntax:1 variables: {{}}Deep query: Through the period symbol. Filter Filter{{var|filter_name}} 2 Tags: {% tag%}Forif ElseFor labelTo iterate through each of the elements:{% for who in person_list%} You can use the {% for obj in list reversed %} reverse to comple
-line shell and scripting environment that enables command-line users (such as Linux-like "ls" commands to display files contained in the current directory) and script writers to take advantage of. 1) Getting Started with Windows PowerShell is primarily for IT pros, programmers, and advanced users who don't have background knowledge of Windows PowerShell.2) How to use: "Ctrl + R"--enter "PowerShell".3) Use "PowerShell" for quick editing, 1-4:Figure 1-4 Opening the quick edit mode for PowerShellT
RequirementsRequest. META is a Python dictionary that contains header information for all HTTP requests, such as the user's IP address and user agent. Through request. Meta.items () can get this dictionary. Requires meta information to be output to a Web page. Output resultsSource Codeindex.htmlviews.pyFrom django.shortcuts import render# Create your views here.def Display_meta (Request): values = Request. Meta.items () html = {} html[' index_title ']= ' Display META ' html[' index_
There are three ways to use the template Views From django.template Import loader, Context, templatefrom django.http import httpresponsefrom django.shortcuts Import renDer_tp_responsedef index1 (req): t = loader.get_template (' index.html ') c = Context ({' usename ': ' Jlan '}) returnHttpResponse (T.render (c)) def INDEX2 (req): t = tempate (' How to use Django templates
Sign up, add apps, select python3.5, then open the console
Build python3.5 Virtual Environment
python --version virtualenv -p /usr/bin/python3.5 VENV source VENV/bin/activate
Installing Django
pip install "django
Create a Web site
django-admin startproject mvote cd mvote python manage.py star
Technorati tags: django, i18n, javascript, Chinese, multi-language
Django's internationalization support is very good and easy to use. It supports code, templates, and JS internationalization solutions. Especially in version 1.2
Local formatting of dates and numbers has been well-developed for internationalization.
Application Method
First, modify settings. py:
1. Add TEMPLATE_CONTEXT_PROCESSORS to
, as long as a day to spend a little time will soon learn. I really want to learn web production friends can often visit my website.
Learn Dede template code
Understand the code before, if you are novice, please use the default template familiar with the Dede system, system settings, how to add columns, how to set the template for the column, how to publish articles, change articles, there is a basic concept.
Dedecms's code is very distinctive, and as
This article collects 25 exquisite freeCSSYou can download and use the website template for free. Believe in these beautiful freeCSSWebsite templates can not only help you save a lot of time and effort, but also provide satisfactory results.Articles you may be interested in
35 exquisite CSS3 and HTML5 webpage templates
Download 12 high-quality and free CSS
You may also like
Share 45 high-quality free HTML/CSS templates
Latest 30 exquisite PSD website templates for free download
27 best website recommendations for web design inspiration
60 Jia Ling feels appreciated by nature's Webpage Design Works
Share the case of 100 beautiful works
In the previousArticleWe introduced a set of cool black single page website templates. Today we bring 12 sets of awesome dedicated administrator website templates!
These awesome website templates can be directly applied to other
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.