Changeset 1301
- Timestamp:
- 11/20/05 10:25:32 (3 years ago)
- Files:
-
- django/branches/new-admin/django/conf/locale/ru/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/new-admin/django/conf/locale/ru/LC_MESSAGES/django.po (modified) (9 diffs)
- django/branches/new-admin/django/contrib/flatpages/middleware.py (modified) (2 diffs)
- django/branches/new-admin/docs/cache.txt (modified) (1 diff)
- django/branches/new-admin/docs/model-api.txt (modified) (1 diff)
- django/branches/new-admin/docs/overview.txt (modified) (3 diffs)
- django/branches/new-admin/docs/syndication_feeds.txt (modified) (1 diff)
- django/branches/new-admin/docs/tutorial01.txt (modified) (1 diff)
- django/branches/new-admin/docs/tutorial03.txt (modified) (5 diffs)
- django/branches/new-admin/docs/url_dispatch.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/conf/locale/ru/LC_MESSAGES/django.po
r1289 r1301 1230 1230 #: models/auth.py:37 1231 1231 msgid "Use an MD5 hash -- not the raw password." 1232 msgstr "éÓÐÏÌØÚÕÊÔÅ MD5 ÈÜÛ -- ÔÏÌØËÏ ÎÅ ÎÅÏÂÒÁÂÏÔÁÎÎÙÊ ÐÁÒÏÌØ "1232 msgstr "éÓÐÏÌØÚÕÊÔÅ MD5 ÈÜÛ -- ÔÏÌØËÏ ÎÅ ÎÅÏÂÒÁÂÏÔÁÎÎÙÊ ÐÁÒÏÌØ." 1233 1233 1234 1234 #: models/auth.py:38 1235 1235 msgid "staff status" 1236 msgstr " "1236 msgstr "ÓÔÁÔÕÓ ÐÅÒÓÏÎÁÌÁ" 1237 1237 1238 1238 #: models/auth.py:38 1239 1239 msgid "Designates whether the user can log into this admin site." 1240 msgstr " "1240 msgstr "ïÔÍÅÔÔÅ, ÅÓÌÉ ÐÏÌØÚÏ×ÁÔÅÌØ ÍÏÖÅÔ ×ÈÏÄÉÔØ × ÁÄÍÉÎ. ÞÁÓÔØ ÓÁÊÔÁ." 1241 1241 1242 1242 #: models/auth.py:39 … … 1261 1261 "all permissions granted to each group he/she is in." 1262 1262 msgstr "" 1263 "ë ÄÏÂÁ×ÌÅÎÉÀ Ë ÐÅÒÁ×ÁÍ ×ÙÂÒÎÁÎÎÙÍ ×ÕÒÕÞÎÕÀ, ÜÔÏÔ ÐÏÌØÚÏ×ÁÔÅÌØ ÍÏÖÅÔ ÐÏÌÕÞÉÔØ " 1264 "×ÓÅ ÐÒÁ×Á ÇÒÕÐÐÙ, Ë ËÏÔÏÒÏÊ ÏÎ ÐÒÉÎÁÄÌÅÖÉÔ." 1263 1265 1264 1266 #: models/auth.py:48 … … 1518 1520 msgid "Watch your mouth! The word %s is not allowed here." 1519 1521 msgid_plural "Watch your mouth! The words %s are not allowed here." 1520 msgstr[0] " "1521 msgstr[1] " "1522 msgstr[0] "óÌÅÄÉÔÅ ÚÁ Ó×ÏÉÍÍÉ ÓÌÏ×ÁÍÉ! óÌÏ×Á %s ÚÄÅÓØ ÚÁÐÒÅÝÅÎÙ." 1523 msgstr[1] "óÌÅÄÉÔÅ ÚÁ Ó×ÏÉÍÍÉ ÓÌÏ×ÁÍÉ! óÌÏ×Á %s ÚÄÅÓØ ÚÁÐÒÅÝÅÎÙ." 1522 1524 1523 1525 #: core/validators.py:235 … … 1546 1548 #: core/validators.py:312 1547 1549 msgid "Duplicate values are not allowed." 1548 msgstr " "1550 msgstr "ä×ÏÊÎÙÅ ÚÎÁÞÅÎÉÑ ÚÁÐÒÅÝÅÎÎÙ." 1549 1551 1550 1552 #: core/validators.py:335 … … 1555 1557 #: core/validators.py:346 1556 1558 msgid "Please enter a valid decimal number." 1557 msgstr " "1559 msgstr "ðÏÖÁÌÕÊÓÔÁ, ××ÏÄÉÔÅ ËÏÒÒÅËÔÎÏÅ ÄÅÓÑÔÉÞÎÏÅ ÞÉÓÌÏ." 1558 1560 1559 1561 #: core/validators.py:348 … … 1562 1564 msgid_plural "" 1563 1565 "Please enter a valid decimal number with at most %s total digits." 1564 msgstr[0] " "1566 msgstr[0] "ðÏÖÁÌÕÊÓÔÁ, ××ÏÄÉÔÅ ËÏÒÒÅËÔÎÏÅ ÄÅÓÑÔÉÞÎÏÅ ÞÉÓÌÏ Ó ÍÁËÓÉÍÁÌØÎÙÍ ËÏÌÉÞÅÓÔ×ÏÍ ÚÎÁËÏ× %s." 1565 1567 msgstr[1] "" 1568 "ðÏÖÁÌÕÊÓÔÁ, ××ÏÄÉÔÅ ËÏÒÒÅËÔÎÏÅ ÄÅÓÑÔÉÞÎÏÅ ÞÉÓÌÏ Ó ÍÁËÓÉÍÁÌØÎÙÍ ËÏÌÉÞÅÓÔ×ÏÍ ÚÎÁËÏ× %s." 1566 1569 1567 1570 #: core/validators.py:351 … … 1570 1573 msgid_plural "" 1571 1574 "Please enter a valid decimal number with at most %s decimal places." 1572 msgstr[0] " "1575 msgstr[0] "ðÏÖÁÌÕÊÓÔÁ, ××ÏÄÉÔÅ ËÏÒÒÅËÔÎÏÅ ÄÅÓÑÔÉÞÎÏÅ ÞÉÓÌÏ Ó ÍÁËÓÉÍÁÌØÎÙÍ ËÏÌÉÞÅÓÔ×ÏÍ ÚÎÁËÏ× ÐÏÓÌÅ ÚÁÐÑÔÏÊ %s." 1573 1576 msgstr[1] "" 1577 "ðÏÖÁÌÕÊÓÔÁ, ××ÏÄÉÔÅ ËÏÒÒÅËÔÎÏÅ ÄÅÓÑÔÉÞÎÏÅ ÞÉÓÌÏ Ó ÍÁËÓÉÍÁÌØÎÙÍ ËÏÌÉÞÅÓÔ×ÏÍ ÚÎÁËÏ× ÐÏÓÌÅ ÚÁÐÑÔÏÊ %s." 1574 1578 1575 1579 #: core/validators.py:361 1576 1580 #, python-format 1577 1581 msgid "Make sure your uploaded file is at least %s bytes big." 1578 msgstr " "1582 msgstr "âÕÄÔÅ Õ×ÅÒÅÎÙ, ÞÔÏ ÚÁÇÒÕÖÅÎÎÙÊ ÆÁÊÌ ÐÏ ËÒÁÊÎÅÊ ÍÅÒÅ ÎÅ ÍÅÎØÛÅ %s ÂÁÊÔ." 1579 1583 1580 1584 #: core/validators.py:362 1581 1585 #, python-format 1582 1586 msgid "Make sure your uploaded file is at most %s bytes big." 1583 msgstr " "1587 msgstr "âÕÄÔÅ Õ×ÅÒÅÎÙ, ÞÔÏ ÚÁÇÒÕÖÅÎÎÙÊ ÆÁÊÌ ÂÏÌØÛÅ ÞÅÍ %s ÂÁÊÔ." 1584 1588 1585 1589 #: core/validators.py:375 1586 1590 msgid "The format for this field is wrong." 1587 msgstr " "1591 msgstr "æÏÒÍÁÔ ÜÔÏÇÏ ÐÏÌÑ ÎÅ×ÅÒÅÎ" 1588 1592 1589 1593 #: core/validators.py:390 1590 1594 msgid "This field is invalid." 1591 msgstr " "1595 msgstr "üÔÏ ÐÏÌÅ ÎÅ×ÅÒÎÏ." 1592 1596 1593 1597 #: core/validators.py:425 1594 1598 #, python-format 1595 1599 msgid "Could not retrieve anything from %s." 1596 msgstr " "1600 msgstr "îÅ×ÏÚÍÏÖÎÏ ÐÏÌÕÞÉÔØ ÞÔÏ ÌÉÂÏ Ó %s." 1597 1601 1598 1602 #: core/validators.py:428 … … 1601 1605 "The URL %(url)s returned the invalid Content-Type header '%(contenttype)s'." 1602 1606 msgstr "" 1607 "URL %(url) ×ÅÒÎÕÌ ÎÅ×ÅÒÎÙ ÚÁÇÏÌÏ×ÏË Content-Type '%(contenttype)'." 1603 1608 1604 1609 #: core/validators.py:461 … … 1656 1661 #: core/meta/fields.py:131 1657 1662 msgid " Separate multiple IDs with commas." 1658 msgstr " "1663 msgstr "òÁÚÄÅÌÑÊÔÅ ÍÎÏÖÅÓÔ×Ï ID ÚÁÐÑÔÏÊ." 1659 1664 1660 1665 #: core/meta/fields.py:134 django/branches/new-admin/django/contrib/flatpages/middleware.py
r1169 r1301 1 1 from django.contrib.flatpages.views import flatpage 2 from django.core.extensions import Http404 2 3 from django.conf.settings import DEBUG 3 4 … … 10 11 # Return the original response if any errors happened. Because this 11 12 # is a middleware, we can't assume the errors will be caught elsewhere. 13 except Http404: 14 return response 12 15 except: 13 16 if DEBUG: django/branches/new-admin/docs/cache.txt
r1223 r1301 94 94 below.) 95 95 96 Then, add the following threerequired settings to your Django settings file:96 Then, add the following required settings to your Django settings file: 97 97 98 98 * ``CACHE_MIDDLEWARE_SECONDS`` -- The number of seconds each page should be django/branches/new-admin/docs/model-api.txt
r1235 r1301 581 581 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 582 582 583 To define a many-to- onerelationship, use ``ManyToManyField``. You use it just583 To define a many-to-many relationship, use ``ManyToManyField``. You use it just 584 584 like any other ``Field`` type: by including it as a class attribute of your 585 585 model. django/branches/new-admin/docs/overview.txt
r1223 r1301 163 163 164 164 urlpatterns = patterns('', 165 (r'^/articles/(?P<year>\d{4})/$', 'myproject.news.views. articles.year_archive'),166 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'myproject.news.views. articles.month_archive'),167 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<article_id>\d+)/$', 'myproject.news.views.article s.article_detail'),165 (r'^/articles/(?P<year>\d{4})/$', 'myproject.news.views.year_archive'), 166 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'myproject.news.views.month_archive'), 167 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<article_id>\d+)/$', 'myproject.news.views.article_detail'), 168 168 ) 169 169 … … 182 182 183 183 For example, if a user requested the URL "/articles/2005/05/39323/", Django 184 would call the function ``myproject.news.views.article s.article_detail(request,184 would call the function ``myproject.news.views.article_detail(request, 185 185 year='2005', month='05', article_id='39323')``. 186 186 … … 281 281 282 282 * A caching framework that integrates with memcached or other backends. 283 * A n RSS framework that makes creating RSS feeds as easy as writing a284 small Python class.283 * A syndication framework that makes creating RSS and Atom feeds as easy as 284 writing a small Python class. 285 285 * More sexy automatically-generated admin features -- this overview barely 286 286 scratched the surface. django/branches/new-admin/docs/syndication_feeds.txt
r1235 r1301 329 329 This example illustrates all possible attributes and methods for a ``Feed`` class:: 330 330 331 class ExampleFeed(rss.Feed): 331 332 from django.contrib.syndication.feeds import Feed 333 from django.utils import feedgenerator 334 335 class ExampleFeed(Feed): 332 336 333 337 # FEED TYPE -- Optional. This should be a class that subclasses django/branches/new-admin/docs/tutorial01.txt
r1269 r1301 95 95 96 96 .. _`Python path documentation`: http://docs.python.org/tut/node8.html#SECTION008110000000000000000 97 .. _Django's ticket system: http://code.djangoproject.com/report/198 97 99 98 Creating models django/branches/new-admin/docs/tutorial03.txt
r1269 r1301 61 61 62 62 For more on ``HTTPRequest`` objects, see the `request and response documentation`_. 63 For more details on URLconfs, see the `URLconf documentation`_. 63 64 64 65 When you ran ``django-admin.py startproject myproject`` at the beginning of … … 68 69 ROOT_URLCONF = 'myproject.urls' 69 70 70 Time for an example. Edit ``myproject/urls.py`` so it looks like 71 this:: 71 Time for an example. Edit ``myproject/urls.py`` so it looks like this:: 72 72 73 73 from django.conf.urls.defaults import * … … 89 89 Finally, it calls that ``detail()`` function like so:: 90 90 91 detail(request=<HttpRequest object>, poll_id= 23)92 93 The ``poll_id= 23`` part comes from ``(?P<poll_id>\d+)``. Using91 detail(request=<HttpRequest object>, poll_id='23') 92 93 The ``poll_id='23'`` part comes from ``(?P<poll_id>\d+)``. Using 94 94 ``(?P<name>pattern)`` "captures" the text matched by ``pattern`` and sends it 95 95 as a keyword argument to the view function. … … 104 104 But, don't do that. It's silly. 105 105 106 Note that these regular expressions do not search GET and POST parameters, or 107 the domain name. For example, in a request to ``http://www.example.com/myapp/``, 108 the URLconf will look for ``/myapp/``. In a request to 109 ``http://www.example.com/myapp/?page=3``, the URLconf will look for ``/myapp/``. 110 106 111 If you need help with regular expressions, see `Wikipedia's entry`_ and the 107 112 `Python documentation`_. Also, the O'Reilly book "Mastering Regular … … 114 119 .. _Python documentation: http://www.python.org/doc/current/lib/module-re.html 115 120 .. _request and response documentation: http://www.djangoproject.com/documentation/request_response/ 121 .. _URLconf documentation: http://www.djangoproject.com/documentation/url_dispatch/ 116 122 117 123 Write your first view django/branches/new-admin/docs/url_dispatch.txt
r1169 r1301 3 3 ============== 4 4 5 We're fanatics about good URLs. No ".php" or ".cgi", and certainly not any of 6 that "0,2097,1-1-1928,00" nonsense. Django's URL dispatcher lets you design 7 your URLs to be as pretty as the rest of your application. 8 9 See `the Django overview`_ for a quick introduction to URL configurations; this 10 document will continue from there. 11 12 .. _`the Django overview`: http://www.djangoproject.com/documentation/overview/#design-your-urls 5 A clean, elegant URL scheme is an important detail in a high-quality Web 6 application. Django lets you design URLs however you want, with no framework 7 limitations. 8 9 There's no ``.php`` or ``.cgi`` required, and certainly none of that 10 ``0,2097,1-1-1928,00`` nonsense. 11 12 See `Cool URIs don't change`_, by World Wide Web creator Tim Berners-Lee, for 13 excellent arguments on why URLs should be clean and usable. 14 15 .. _Cool URIs don't change: http://www.w3.org/Provider/Style/URI 16 17 Overview 18 ======== 19 20 To design URLs for an app, you create a Python module informally called a 21 **URLconf** (URL configuration). This module is pure Python code and 22 is a simple mapping between URL patterns (as simple regular expressions) to 23 Python callback functions (your views). 24 25 This mapping can be as short or as long as needed. It can reference other 26 mappings. And, because it's pure Python code, it can be constructed 27 dynamically. 28 29 How Django processes a request 30 ============================== 31 32 When a user requests a page from your Django-powered site, this is the 33 algorithm the system follows to determine which Python code to execute: 34 35 1. The system looks at the ``ROOT_URLCONF`` setting in your 36 `settings file`_. This should be a string representing the full Python 37 import path to your URLconf. For example: ``"mydjangoapps.urls"``. 38 2. The system loads that Python module and looks for the variable 39 ``urlpatterns``. This should be a Python list, in the format returned 40 by the function ``django.conf.urls.defaults.patterns()``. 41 3. The system runs through each URL pattern, in order, and stops at the 42 first one that matches the requested URL. 43 4. Once one of the regexes matches, Django imports and calls the given 44 view, which is a simple Python function. The view gets passed a 45 `request object`_ and any values captured in the regex as keyword 46 arguments. 47 48 .. _settings file: http://www.djangoproject.com/documentation/settings/ 49 .. _request object: http://www.djangoproject.com/documentation/request_response/#httprequest-objects 50 51 Example 52 ======= 53 54 Here's a sample URLconf:: 55 56 from django.conf.urls.defaults import * 57 58 urlpatterns = patterns('', 59 (r'^/articles/2003/$', 'news.views.special_case_2003'), 60 (r'^/articles/(?P<year>\d{4})/$', 'news.views.year_archive'), 61 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'news.views.month_archive'), 62 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', 'news.views.article_detail'), 63 ) 64 65 Notes: 66 67 * ``from django.conf.urls.defaults import *`` makes the ``patterns`` 68 function available. 69 70 * To capture a value from the URL, use the syntax ``(?P<name>pattern)``, 71 where ``name`` is the name for that value and ``pattern`` is some pattern 72 to match. 73 74 * The ``"r"`` in front of each regular expression string is optional but 75 recommended. It tells Python that a string is "raw" -- that nothing in 76 the string should be escaped. See `Dive Into Python's explanation`_. 77 78 Examples: 79 80 * A request to ``/articles/2005/03/`` would match the third entry in the 81 list. Django would call the function 82 ``news.views.month_archive(request, year='2005', month='03')``. 83 84 * ``/articles/2005/3/`` would not match any URL patterns, because the 85 third entry in the list requires two digits for the month. 86 87 * ``/articles/2003/`` would match the first pattern in the list, not the 88 second one, because the patterns are tested in order, and the first one 89 is the first test to pass. Feel free to exploit the ordering to insert 90 special cases like this. 91 92 * ``/articles/2003`` would not match any of these patterns, because each 93 pattern requires that the URL end with a slash. 94 95 * ``/articles/2003/03/3/`` would match the final pattern. Django would call 96 the function 97 ``news.views.article_detail(request, year='2003', month='03', day='3')``. 98 99 .. _Dive Into Python's explanation: http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3 100 101 What the URLconf searches against 102 ================================= 103 104 The URLconf searches against the requested URL, as a normal Python string. This 105 does not include GET or POST parameters, or the domain name. 106 107 For example, in a request to ``http://www.example.com/myapp/``, the URLconf 108 will look for ``/myapp/``. 109 110 In a request to ``http://www.example.com/myapp/?page=3``, the URLconf will look 111 for ``/myapp/``. 112 113 Syntax of the urlpatterns variable 114 ================================== 115 116 ``urlpatterns`` should be a Python list, in the format returned by the function 117 ``django.conf.urls.defaults.patterns()``. Always use ``patterns()`` to create 118 the ``urlpatterns`` variable. 119 120 Convention is to use ``from django.conf.urls.defaults import *`` at the top of 121 your URLconf. This gives your module access to these objects: 122 123 patterns 124 -------- 125 126 A function that takes a prefix an arbitrary number of URL patterns and returns 127 a list of URL patterns in the format Django needs. 128 129 The first argument to ``patterns()`` is a string ``prefix``. See 130 "The view prefix" below. 131 132 The remaining arguments should be tuples in this format:: 133 134 (regular expression, Python callback function [, optional dictionary]) 135 136 ...where ``dictionary_of_extra_arguments`` is optional. (See 137 "Passing extra options to view functions" below.) 138 139 handler404 140 ---------- 141 142 A string representing the full Python import path to the view that should be 143 called if none of the URL patterns match. 144 145 By default, this is ``'django.views.defaults.page_not_found'``. That default 146 value should suffice. 147 148 handler500 149 ---------- 150 151 A string representing the full Python import path to the view that should be 152 called in case of server errors. Server errors happen when you have runtime 153 errors in view code. 154 155 By default, this is ``'django.views.defaults.server_error'``. That default 156 value should suffice. 157 158 include 159 ------- 160 161 A function that takes a full Python import path to another URLconf that should 162 be "included" in this place. See "Including other URLconfs" below. 163 164 Notes on capturing text in URLs 165 =============================== 166 167 Each captured argument is sent to the view as a plain Python string, regardless 168 of what sort of match the regular expression makes. For example, in this 169 URLconf:: 170 171 (r'^/articles/(?P<year>\d{4})/$', 'news.views.year_archive'), 172 173 ...the ``year`` argument to ``news.views.year_archive()`` will be a string, not 174 an integer, even though the ``\d{4}`` will only match integer strings. 175 176 A convenient trick is to specify default parameters for your views' arguments. 177 Here's an example URLconf and view:: 178 179 # URLconf 180 urlpatterns = patterns('', 181 (r'^/blog/$', 'blog.views.page'), 182 (r'^/blog/page(?P<num>\d+)/$', 'blog.views.page'), 183 ) 184 185 # View (in blog/views.py) 186 def page(request, num="1"): 187 # Output the appropriate page of blog entries, according to num. 188 189 In the above example, both URL patterns point to the same view -- 190 ``blog.views.page`` -- but the first pattern doesn't capture anything from the 191 URL. If the first pattern matches, the ``page()`` function will use its 192 default argument for ``num``, ``"1"``. If the second pattern matches, 193 ``page()`` will use whatever ``num`` value was captured by the regex. 194 195 Performance 196 =========== 197 198 Each regular expression in a ``urlpatterns`` is compiled the first time it's 199 accessed. This makes the system blazingly fast. 13 200 14 201 The view prefix 15 202 =============== 16 203 17 Here's the example from that overview:: 18 19 from django.conf.urls.defaults import * 20 21 urlpatterns = patterns('', 22 (r'^/articles/(?P<year>\d{4})/$', 'myproject.news.views.articles.year_archive'), 23 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'myproject.news.views.articles.month_archive'), 24 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', 'myproject.news.views.articles.article_detail'), 25 ) 26 27 The first argument to ``patterns`` is an empty string in the above example, but 28 that argument can be useful. The first argument is prepended to all the view 29 functions in the urlpatterns list, so the above example could be written more 30 concisely as:: 31 32 urlpatterns = patterns('myproject.news.views.articles', 204 You can specify a common prefix in your ``patterns()`` call, to cut down on 205 code duplication. 206 207 Here's the example URLconf from the `Django overview`_:: 208 209 from django.conf.urls.defaults import * 210 211 urlpatterns = patterns('', 212 (r'^/articles/(?P<year>\d{4})/$', 'myproject.news.views.year_archive'), 213 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'myproject.news.views.month_archive'), 214 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', 'myproject.news.views.article_detail'), 215 ) 216 217 In this example, each view has a common prefix -- ``"myproject.news.views"``. 218 Instead of typing that out for each entry in ``urlpatterns``, you can use the 219 first argument to the ``patterns()`` function to specify a prefix to apply to 220 each view function. 221 222 With this in mind, the above example can be written more concisely as:: 223 224 from django.conf.urls.defaults import * 225 226 urlpatterns = patterns('myproject.news.views', 33 227 (r'^/articles/(?P<year>\d{4})/$', 'year_archive'), 34 228 (r'^/articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'month_archive'), … … 36 230 ) 37 231 38 .. admonition:: Note 39 40 More precisely, the actual view function used is ``prefix + "." + 41 function_name``. The trailing "dot" does not need to be put in the prefix. 232 Note that you don't put a trailing dot (``"."``) in the prefix. Django puts 233 that in automatically. 234 235 .. _Django overview: http://www.djangoproject.com/documentation/overview/ 42 236 43 237 Including other URLconfs 44 238 ======================== 45 239 46 You can also "include" other URLconf modules at any point along the path. This47 essentially "roots" a set of URLs below other ones. This is most often used48 for a site's "base" URLconf; the ``ROOT_URLCONF`` setting points to a urlconf 49 module that will be used for the entire site. Here's the URLconf for the 50 `Django website`_ itself. It includes anumber of other URLconfs::240 At any point, your ``urlpatterns`` can "include" other URLconf modules. This 241 essentially "roots" a set of URLs below other ones. 242 243 For example, here's the URLconf for the `Django website`_ itself. It includes a 244 number of other URLconfs:: 51 245 52 246 from django.conf.urls.defaults import * … … 71 265 (r'^$', 'blog.index'), 72 266 (r'^archive/$', 'blog.archive'), 267 ) 73 268 74 269 In the above example, the captured ``"username"`` variable is passed to the … … 80 275 ======================================= 81 276 82 There are two ways of passing arguments into your view functions: named captures 83 from the regex (which you've already seen) and the optional third element 84 in URLconf tuples. This third element can be a dictionary of extra keyword 85 arguments that will be passed to the view function:: 86 87 urlpatterns = patterns('myproject.news.views.articles', 88 (r'^/articles/(?P<year>\d{4})/$', 'year_archive', {key: value, key2: value2}), 89 ) 277 URLconfs have a hook that lets you pass extra arguments to your view functions, 278 as a Python dictionary. 279 280 Any URLconf tuple can have an optional third element, which should be a 281 dictionary of extra keyword arguments to pass to the view function. 282 283 For example:: 284 285 urlpatterns = patterns('blog.views', 286 (r'^/blog/(?P<year>\d{4})/$', 'year_archive', {'foo': 'bar'}), 287 ) 288 289 In this example, for a request to ``/blog/2005/``, Django will call the 290 ``blog.views.year_archive()`` view, passing it these keyword arguments:: 291 292 year='2005', foo='bar' 293 294 This technique is used in `generic views`_ and in the `syndication framework`_ 295 to pass metadata and options to views. 296 297 .. _generic views: http://www.djangoproject.com/documentation/generic_views/ 298 .. _syndication framework: http://www.djangoproject.com/documentation/syndication/
