- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Django URL调度详述(国外英文资料)
Django URL调度详述(国外英文资料)
For high quality WEB applications, there is a clean and elegant the URL of the scheduling mechanism is crucial. Django allows you to design URLs according to need, no framework layer.
There is no need for.php or.cgi extensions or ugly things like 0, 20971-1-1928,00.
See the Cool URIs dont change written by Tim berners-lee, the creator of WWW. The topic of this article is why the URL should be clean and easy to use.
1 overview
For an application design URLs, to generate a called URLconf informal Python module (URL). The module is pure Python code, its role is in the URL patterns (a simple regular expression) and Python callback function mapping between (your views).
This fundamental need mapping can be very short, can be very long. It can refer to other mapping. Because it is pure Python code, and have the ability to dynamically create the mapping.
How Django handles a request (request)
When the user requests a page, the following algorithm determines which Python code to execute:
Django first checks for ROOT_URLCONF Settings in the Settings file. This is an absolute path string for Python imports URLconf. For example: mydjangoapps. Urls.
Django loads the Python module and looks for the variable urlpatterns. The variable is a list of elements of a Django.conf.
The Django sequence handles each URL pattern until you find a pattern matching the request URL.
Once the match is successful, the Django import and call the corresponding view, namely the corresponding Python functions. This view function will get a request object as its first parameter, in the regular expression match other values are passed to the view as other parameters.
Example 3
Here is an example of URLconf:
From the django. Conf. Urls. Defaults import * urlpatterns = patterns ( , (r ^ articles / 2003 / $, news. Views. Special_case_2003 ), (r ^ articles/(d {4}) / $, news. Views. Year_archive ), (r ^ articles/(d {4})/(d {2}) / $, news. Views. Month_archive ), (r ^ articles/(d {4})/(
您可能关注的文档
最近下载
- 2024年中国石油东方地球物理勘探有限责任公司秋季高校毕业生招聘270人(甘肃有岗)笔试备考试题及答案解析.docx
- 天马旅游汽车公司管理职责、制度汇编.doc
- 从领导力角度说耿彦波——.ppt
- 唐山介绍PPT(唐山简介经典版).pptx
- 《我的家庭贡献与责任》第一课时小学道德与法治四年级上册PPT课件.pptx VIP
- 保养手册_迈腾b7l使用说明书.pdf
- 2024-2025人教版3三年级数学上册(全册)优秀测试卷(附答案).doc
- (2024年1月)广西各市房屋工程造价指标.doc VIP
- 2022年11月苏州城市学院下半年公开招聘27名管理岗位工作人员笔试参考题库含答案解析.docx
- 2023年义务教育初中英语新课标《英语新课程标准》解读ppt课件.pptx VIP
文档评论(0)