Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added some links in /docs/intro/overview.txt

Thanks Claes Ström for the patch.
  • Loading branch information...
commit bdde7feb26f89e580c2b21154196fe3f8c774677 1 parent f7d7d2b
Tim Graham authored May 19, 2013
2  docs/howto/custom-template-tags.txt
@@ -72,6 +72,8 @@ following:
72 72
 
73 73
     For more information on the :ttag:`load` tag, read its documentation.
74 74
 
  75
+.. _howto-writing-custom-template-filters:
  76
+
75 77
 Writing custom template filters
76 78
 -------------------------------
77 79
 
40  docs/intro/overview.txt
@@ -16,15 +16,17 @@ Design your model
16 16
 =================
17 17
 
18 18
 Although you can use Django without a database, it comes with an
19  
-object-relational mapper in which you describe your database layout in Python
  19
+`object-relational mapper`_ in which you describe your database layout in Python
20 20
 code.
21 21
 
  22
+.. _object-relational mapper: http://en.wikipedia.org/wiki/Object-relational_mapping
  23
+
22 24
 The :doc:`data-model syntax </topics/db/models>` offers many rich ways of
23 25
 representing your models -- so far, it's been solving two years' worth of
24 26
 database-schema problems. Here's a quick example, which might be saved in
25 27
 the file ``mysite/news/models.py``::
26 28
 
27  
-    from django.db import models 
  29
+    from django.db import models
28 30
 
29 31
     class Reporter(models.Model):
30 32
         full_name = models.CharField(max_length=70)
@@ -57,8 +59,9 @@ tables in your database for whichever tables don't already exist.
57 59
 Enjoy the free API
58 60
 ==================
59 61
 
60  
-With that, you've got a free, and rich, :doc:`Python API </topics/db/queries>` to
61  
-access your data. The API is created on the fly, no code generation necessary:
  62
+With that, you've got a free, and rich, :doc:`Python API </topics/db/queries>`
  63
+to access your data. The API is created on the fly, no code generation
  64
+necessary:
62 65
 
63 66
 .. code-block:: python
64 67
 
@@ -135,9 +138,9 @@ A dynamic admin interface: it's not just scaffolding -- it's the whole house
135 138
 ============================================================================
136 139
 
137 140
 Once your models are defined, Django can automatically create a professional,
138  
-production ready :doc:`administrative interface </ref/contrib/admin/index>` -- a Web
139  
-site that lets authenticated users add, change and delete objects. It's as easy
140  
-as registering your model in the admin site::
  141
+production ready :doc:`administrative interface </ref/contrib/admin/index>` --
  142
+a Web site that lets authenticated users add, change and delete objects. It's
  143
+as easy as registering your model in the admin site::
141 144
 
142 145
     # In models.py...
143 146
 
@@ -173,9 +176,9 @@ application. Django encourages beautiful URL design and doesn't put any cruft
173 176
 in URLs, like ``.php`` or ``.asp``.
174 177
 
175 178
 To design URLs for an app, you create a Python module called a :doc:`URLconf
176  
-</topics/http/urls>`. A table of contents for your app, it contains a simple mapping
177  
-between URL patterns and Python callback functions. URLconfs also serve to
178  
-decouple URLs from Python code.
  179
+</topics/http/urls>`. A table of contents for your app, it contains a simple
  180
+mapping between URL patterns and Python callback functions. URLconfs also serve
  181
+to decouple URLs from Python code.
179 182
 
180 183
 Here's what a URLconf might look like for the ``Reporter``/``Article``
181 184
 example above::
@@ -188,7 +191,7 @@ example above::
188 191
         (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
189 192
     )
190 193
 
191  
-The code above maps URLs, as simple regular expressions, to the location of
  194
+The code above maps URLs, as simple `regular expressions`_, to the location of
192 195
 Python callback functions ("views"). The regular expressions use parenthesis to
193 196
 "capture" values from the URLs. When a user requests a page, Django runs
194 197
 through each pattern, in order, and stops at the first one that matches the
@@ -196,6 +199,8 @@ requested URL. (If none of them matches, Django calls a special-case 404 view.)
196 199
 This is blazingly fast, because the regular expressions are compiled at load
197 200
 time.
198 201
 
  202
+.. _regular expressions: http://docs.python.org/2/howto/regex.html
  203
+
199 204
 Once one of the regexes matches, Django imports and calls the given view, which
200 205
 is a simple Python function. Each view gets passed a request object --
201 206
 which contains request metadata -- and the values captured in the regex.
@@ -216,7 +221,7 @@ Generally, a view retrieves data according to the parameters, loads a template
216 221
 and renders the template with the retrieved data. Here's an example view for
217 222
 ``year_archive`` from above::
218 223
 
219  
-    from django.shortcuts import render_to_response 
  224
+    from django.shortcuts import render_to_response
220 225
 
221 226
     def year_archive(request, year):
222 227
         a_list = Article.objects.filter(pub_date__year=year)
@@ -233,8 +238,8 @@ The code above loads the ``news/year_archive.html`` template.
233 238
 
234 239
 Django has a template search path, which allows you to minimize redundancy among
235 240
 templates. In your Django settings, you specify a list of directories to check
236  
-for templates. If a template doesn't exist in the first directory, it checks the
237  
-second, and so on.
  241
+for templates with :setting:`TEMPLATE_DIRS`. If a template doesn't exist in the
  242
+first directory, it checks the second, and so on.
238 243
 
239 244
 Let's say the ``news/year_archive.html`` template was found. Here's what that
240 245
 might look like:
@@ -265,9 +270,10 @@ character). This is called a template filter, and it's a way to filter the value
265 270
 of a variable. In this case, the date filter formats a Python datetime object in
266 271
 the given format (as found in PHP's date function).
267 272
 
268  
-You can chain together as many filters as you'd like. You can write custom
269  
-filters. You can write custom template tags, which run custom Python code behind
270  
-the scenes.
  273
+You can chain together as many filters as you'd like. You can write :ref:`custom
  274
+template filters <howto-writing-custom-template-filters>`. You can write
  275
+:doc:`custom template tags </howto/custom-template-tags>`, which run custom
  276
+Python code behind the scenes.
271 277
 
272 278
 Finally, Django uses the concept of "template inheritance": That's what the
273 279
 ``{% extends "base.html" %}`` does. It means "First load the template called

0 notes on commit bdde7fe

Please sign in to comment.
Something went wrong with that request. Please try again.