Django:什么是“加载”做(在模板文件)? [英] Django: what does "load" do (in a template file)?
问题描述
由于加载对于搜索来说太普遍:
-
加载的目的是什么?在这种特殊情况下呢? - 在模板文件中,base_weblog.html
{%load weblog%} {%render_month_links%}
-
为了加载到
,是否使用了一些命名约定?例如。文件夹和/或文件的名称和/或
类名称? -
加载的文档在哪里,您可以详细说明? p>
详细信息:
示例来自
的来源 http://www.djangoproject.com/ - 直接下载网址是
,通过 http://shrinkster.com/17g8 。
部分文件夹结构(没有文件扩展名的项目是文件夹):
django_website
应用程序
帐户
聚合器
博客
urls.py
models.py
类条目(models.Model)
templatetags
weblog.py
联系
docs
模板
base_weblog.html
聚合器
blog
entry_archive.html
entry_archive_year.html
mon th_links_snippet.html
entry_archive_month.html
entry_detail.html
entry_snippet.html
entry_archive_day.html
评论
联系
docs
feed
flatfiles
flatpages
注册
django_website / templates / base_weblog.html
)中的div> weblog指文件 weblog.py
在文件夹 django_website / apps / blog / templatetags
中。文件夹 templatetags
必须完全命名,并且必须包含名为 __ init __。py
(问题2)的文件。
加载使自定义模板标签( render_latest_blog_entries
和 render_month_links
在这种情况下)可用于模板, django_website\templates\base_weblog.html
在这种情况下。 加载是一种安全和性能功能。
As "load" is far too generic for searching:
What is the purpose of "load" and what does it do in this particular case? - in a template file, base_weblog.html,
{% load weblog %}{% render_month_links %}
Are some naming conventions used in order for "load" to do its job? E.g. names of folders and/or files and/or class names?
Where is the documentation for "load" and can you elaborate?
Details:
The example is from the source for http://www.djangoproject.com/ - direct download URL is through http://shrinkster.com/17g8.
Partial folder structure (items with no file extension are folders):
django_website
apps
accounts
aggregator
blog
urls.py
models.py
class Entry(models.Model)
templatetags
weblog.py
contact
docs
templates
base_weblog.html
aggregator
blog
entry_archive.html
entry_archive_year.html
month_links_snippet.html
entry_archive_month.html
entry_detail.html
entry_snippet.html
entry_archive_day.html
comments
contact
docs
feeds
flatfiles
flatpages
registration
"weblog" after "load" (in template file django_website/templates/base_weblog.html
) refers to file weblog.py
in folder django_website/apps/blog/templatetags
. Folder templatetags
must be named exactly that and must contain a file named __init__.py
(question 2).
"load" makes the custom template tags (render_latest_blog_entries
and render_month_links
in this case) available for use in templates, django_website\templates\base_weblog.html
in this case. "Load" is a security and performance function.
这篇关于Django:什么是“加载”做(在模板文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!