From 7e5c20ace49928e5962e05a2f4c2fd345f3a27f8 Mon Sep 17 00:00:00 2001 From: xiayh <xiayh2012@gmail.com> Date: Sun, 25 Nov 2012 11:32:32 -0600 Subject: [PATCH] Update docs/intro/tutorial03.txt --- docs/intro/tutorial03.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 5ed927a..303860a 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -48,6 +48,9 @@ The first step of writing views is to design your URL structure. You do this by creating a Python module, called a URLconf. URLconfs are how Django associates a given URL with given Python code. +第一步是设计URL结构。首先创建Python模块,并命名为URLconf。Django通过URLconf连接 +和给定的URL和Python代码。 + When a user requests a Django-powered page, the system looks at the :setting:`ROOT_URLCONF` setting, which contains a string in Python dotted syntax. Django loads that module and looks for a module-level variable called @@ -59,6 +62,15 @@ Django starts at the first regular expression and makes its way down the list, comparing the requested URL against each regular expression until it finds one that matches. +当用户获取一个Django页面,系统会查询 :setting:`ROOT_URLCONF`环境。`ROOT_URLCONF`含有 +Python语法中的字符串。Django载入指定模版并定位名为``urlpatterns``的变量。 +``urlpatterns``格式如下:: + + (regular expression, Python callback function [, optional dictionary]) + +Django从第一个表达式开始读取整个list,比较requested URL和list中的每个表达式, +直到找到符合的配对。 + When it finds a match, Django calls the Python callback function, with an :class:`~django.http.HttpRequest` object as the first argument, any "captured" values from the regular expression as keyword arguments, and, optionally,