...What is a template?A template is a reusable file that renders dynamic content using a fixed format. For example, you can use a template to write messages, each message may have different content, sent to different people, but their format is the same.Django template using HTML files, as for God Horse is HTML, this
In the previous chapter, we completed the basic functions of admin, but the appearance of it is too ugly, then we will try to change it ~
If you want to change it, you'll use Django's templating system. Because admin is a Django-brought app, he uses a Django-brought template system.
First you need to create a te
Django 1.10 Chinese Document-First Application Part3-view and template, djangopart3-
This tutorial is based on the Django 1.10 Chinese document-the first application Part2-model and management site. We will continue to develop the web page voting application, mainly about how to create an open interface for users.Overview
A view is a "class" webpage in a
Python Django template usage, pythondjango Template
A template is a text that is used to separate the representation and content of a document. A template defines placeholders and various basic logics (template tags) used to demon
is optional. If this field is set, create a static empty folder under hello.
MEDIA_ROOT = OS. path. join (PROJECT_DIR, 'static ')
# Add the following sentence in TEMPLATE_DIR = (
OS. path. join (PROJECT_DIR, 'template '),
# The following two sentences are added at the end of INSTALLED_APPS = (
# The admin page cannot be accessed without the following sentence
'Django. contrib. admin ',
'Hello.
: http: // 121.42.156.185: 8000/getmovielist/(the domain name is not filed for record .. That's it. About 16000 movies can be played)
Github address: https://github.com/pureYun/dnomovie
Maintain the pace of adding at least two features every week. Students are mainly studying .. Front-end slag
The next step is to perform regular task crawling and follow-up on users and add friends... You are welcome to supervise the Django framework. If you have pytho
. py file to make the notebook list more beautiful, and add it to the registration code.
From Django. DB import models
From Django. contrib import Admin
Class blogpost (models. Model ):
Title = models. charfield (max_length = 150)
Body = models. textfield ()
Timestamp = models. datetimefield ()
Class meta:
Ordering = ('-timestamp ',)
Class blogpostadmin (Admin. modeladmin ):
List_display = ('title', 'times
Catalogueone, Django URL Applicationsecond, Django View Applicationthird, Django Template ApplicationIv. Django's ORM ApplicationAdd:Supplement One: GetlisApplication Scenario: The current side of the data sent at multiple times, the background if you also get data with get, then there will be a problem, so there is a
Django learning notes (5) template tags, django learning notes
About Django template tag official site https://docs.djangoproject.com/en/1.11/ref/templates/builtins/
1. IF tag
Hello World/views. py
1 from django. shortcuts import
./manage.py runserver command, and then enter http://127.0.0.1:8000/admin/in the browser, a login window will appearAfter logging in using the Superuser username and password, the following interface appears:Click Add after blogpost, inside will appear in the model of the three elements title, body, Timestampe, add and click Save;Add a Blogpostadmin class to the models.py file and add it to the registration code: fromDjango.dbImportModels fromDjango.contribImportAdminclassblogpost (models. Model
and template labels, this is what it looks like.
See blog_list.html first
Add Comment
The Django forms module can be used to easily integrate the comment function.We need to create a new form. py in the Blog application for processing.
# Coding: utf-8from django import forms "to achieve
is where our future data comes in. The associated format control, the We need to specify the search path to the Django template file, modify the mysite/settings.py, and add:
# Template Dir
Template_dirs = (
Os.path.join (Base_dir, ' templates/west/'),
)
If there are other paths to hold the template
Foreword: Recently prepares to write a own personal blog. Originally intended to be developed with. NET, since vs is a bit of a load, recently learning Python. Select the Python web frame Django.development environment: Ubuntu 14.04Development tools: Pychram 2016.1.0 Community Editionpython version: 2.7.6Django version: 1.9.6Here's the start:1. Tool Installation:Python has taken its own; open PychramFile–>settings–>project **–>project InterpreterClick
from the model, so that we can get all the article content in the database in line fifth, with BlogPost.objects.all ().Line 6th: We can create a template object T just by telling the name of the Django template, because the template is saved in the app's Templates folder, so Djang
Django Build blog site (iii)The third chapter mainly records the logic and template of the view layer.Django Build blog site (i)Django Build blog site (ii)StructureThe structure of the website determines what view I want to achiev
Django Build blog site (iv)The last article mainly talk about in the background article editor joins Markdown, already in the article detail page to the markdown parsing.Django Build blog site (i)Django Build blog site (ii)Django
Converter 2: Convert ThinkPhp template to Django template, thinkphpdjango
I wrote a ThinkPhp template to Flask template the day before yesterday.
He was despised by his colleagues because he used Django. I used Flask to avoid hi
The day before yesterday wrote a "thinkphp template to Flask template"I was despised by my colleague because he was using Django, and I used flask to avoid being so powerful as he continued to be with the Amway Django. I decided to write a Django
This article describes several common tags:1.if Tags: {% if%} ... {% ENDIF%}2.for Tags: {% for%} ... {% ENDFOR%}3. Compare Tags: {% ifequal/ifnotequal%} ... {% endifequal/endifnotequal%}4. Note Label: {% comment%} ... {% Endcomment%}Templateis a plain text file, or a plain Python string that has been tagged with the Django template language. Templates can contain templa
|filter_multi:30 >%} {{num|filter_multi:30 }}{% endif%}6, template inheritance (extend)The most powerful and complex part of the Django template engine is the template inheritance. Template inheritance lets you create a basic "skeleton"
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.