Django URL调度详述(国外英文资料).doc

  1. 1、本文档共12页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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})/(

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档