diff -r 07be6b6eaea0 docs/ref/contrib/admin.txt
a
|
b
|
To continue the example above, we want t
|
924 | 924 | To continue the example above, we want to add a new link next to the ``History`` |
925 | 925 | tool for the ``Page`` model. After looking at ``change_form.html`` we determine |
926 | 926 | that we only need to override the ``object-tools`` block. Therefore here is our |
927 | | new ``change_form.html`` :: |
| 927 | new ``change_form.html`` : |
| 928 | |
| 929 | .. code-block:: html+django |
928 | 930 | |
929 | 931 | {% extends "admin/change_form.html" %} |
930 | 932 | {% load i18n %} |
diff -r 07be6b6eaea0 docs/ref/contrib/comments/index.txt
a
|
b
|
Django's comments framework
|
6 | 6 | |
7 | 7 | .. module:: django.contrib.comments |
8 | 8 | :synopsis: Django's comment framework |
| 9 | |
| 10 | .. highlightlang:: html+django |
9 | 11 | |
10 | 12 | Django includes a simple, yet customizable comments framework. The built-in |
11 | 13 | comments framework can be used to attach comments to any model, so you can use |
diff -r 07be6b6eaea0 docs/ref/contrib/formtools/form-wizard.txt
a
|
b
|
You can specify it in two ways:
|
169 | 169 | * Pass :attr:`~django.contrib.formtools.wizard.FormWizard.extra_context` |
170 | 170 | as extra parameters in the URLconf. |
171 | 171 | |
172 | | Here's a full example template:: |
173 | | |
| 172 | Here's a full example template: |
| 173 | |
| 174 | .. code-block:: html+django |
| 175 | |
174 | 176 | {% extends "base.html" %} |
175 | 177 | |
176 | 178 | {% block content %} |
diff -r 07be6b6eaea0 docs/ref/django-admin.txt
a
|
b
|
makemessages
|
385 | 385 | ------------ |
386 | 386 | |
387 | 387 | .. versionchanged:: 1.0 |
388 | | Before 1.0 this was the "bin/make-messages.py" command. |
| 388 | Before 1.0 this was the ``bin/make-messages.py`` command. |
389 | 389 | |
390 | 390 | Runs over the entire source tree of the current directory and pulls out all |
391 | 391 | strings marked for translation. It creates (or updates) a message file in the |
diff -r 07be6b6eaea0 docs/ref/files/file.txt
a
|
b
|
Additional ``ImageField`` attributes
|
88 | 88 | |
89 | 89 | .. attribute:: File.height |
90 | 90 | |
91 | | Heigght of the image. |
| 91 | Height of the image. |
92 | 92 | |
93 | 93 | Additional methods on files attached to objects |
94 | 94 | ----------------------------------------------- |
diff -r 07be6b6eaea0 docs/ref/request-response.txt
a
|
b
|
All attributes except ``session`` should
|
93 | 93 | A standard Python dictionary containing all cookies. Keys and values are |
94 | 94 | strings. |
95 | 95 | |
96 | | .. attribute:: HttpRequest.FILES |
97 | | |
98 | | .. admonition:: Changed in Django development version |
99 | | |
100 | | In previous versions of Django, ``request.FILES`` contained |
101 | | simple ``dict`` objects representing uploaded files. This is |
102 | | no longer true -- files are represented by ``UploadedFile`` |
103 | | objects as described below. |
104 | | |
105 | | These ``UploadedFile`` objects will emulate the old-style ``dict`` |
106 | | interface, but this is deprecated and will be removed in the next |
107 | | release of Django. |
| 96 | .. attribute:: HttpRequest.FILES |
108 | 97 | |
109 | 98 | A dictionary-like object containing all uploaded files. Each key in |
110 | 99 | ``FILES`` is the ``name`` from the ``<input type="file" name="" />``. Each |
… |
… |
All attributes except ``session`` should
|
122 | 111 | and the ``<form>`` that posted to the request had |
123 | 112 | ``enctype="multipart/form-data"``. Otherwise, ``FILES`` will be a blank |
124 | 113 | dictionary-like object. |
| 114 | |
| 115 | .. versionchanged:: 1.0 |
| 116 | |
| 117 | In previous versions of Django, ``request.FILES`` contained simple ``dict`` |
| 118 | objects representing uploaded files. This is no longer true -- files are |
| 119 | represented by ``UploadedFile`` objects as described below. |
| 120 | |
| 121 | These ``UploadedFile`` objects will emulate the old-style ``dict`` |
| 122 | interface, but this is deprecated and will be removed in the next release of |
| 123 | Django. |
125 | 124 | |
126 | 125 | .. attribute:: HttpRequest.META |
127 | 126 | |
diff -r 07be6b6eaea0 docs/ref/templates/api.txt
a
|
b
|
content from a database or enable access
|
29 | 29 | |
30 | 30 | Block tags are surrounded by ``"{%"`` and ``"%}"``. |
31 | 31 | |
32 | | Example template with block tags:: |
| 32 | Example template with block tags: |
| 33 | |
| 34 | .. code-block:: html+django |
33 | 35 | |
34 | 36 | {% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{% endif %} |
35 | 37 | |
… |
… |
A **variable** is a symbol within a temp
|
37 | 39 | |
38 | 40 | Variable tags are surrounded by ``"{{"`` and ``"}}"``. |
39 | 41 | |
40 | | Example template with variables:: |
| 42 | Example template with variables: |
| 43 | |
| 44 | .. code-block:: html+django |
41 | 45 | |
42 | 46 | My first name is {{ first_name }}. My last name is {{ last_name }}. |
43 | 47 | |
… |
… |
returns the resulting string::
|
566 | 570 | |
567 | 571 | The ``render_to_string`` shortcut takes one required argument -- |
568 | 572 | ``template_name``, which should be the name of the template to load |
569 | | and render -- and two optional arguments:: |
| 573 | and render -- and two optional arguments: |
570 | 574 | |
571 | 575 | dictionary |
572 | 576 | A dictionary to be used as variables and values for the |
diff -r 07be6b6eaea0 docs/ref/templates/builtins.txt
a
|
b
|
documentation for any custom tags or fil
|
13 | 13 | |
14 | 14 | Built-in tag reference |
15 | 15 | ---------------------- |
| 16 | |
| 17 | .. highlightlang:: html+django |
16 | 18 | |
17 | 19 | .. templatetag:: autoescape |
18 | 20 | |
… |
… |
Regroup a list of alike objects by a com
|
473 | 475 | |
474 | 476 | This complex tag is best illustrated by use of an example: say that ``people`` |
475 | 477 | is a list of people represented by dictionaries with ``first_name``, |
476 | | ``last_name``, and ``gender`` keys:: |
| 478 | ``last_name``, and ``gender`` keys: |
| 479 | |
| 480 | .. code-block:: python |
477 | 481 | |
478 | 482 | people = [ |
479 | 483 | {'first_name': 'George', 'last_name': 'Bush', 'gender': 'Male'}, |
… |
… |
If the ``people`` list did *not* order i
|
530 | 534 | If the ``people`` list did *not* order its members by ``gender``, the regrouping |
531 | 535 | would naively display more than one group for a single gender. For example, |
532 | 536 | say the ``people`` list was set to this (note that the males are not grouped |
533 | | together):: |
| 537 | together): |
| 538 | |
| 539 | .. code-block:: python |
534 | 540 | |
535 | 541 | people = [ |
536 | 542 | {'first_name': 'Bill', 'last_name': 'Clinton', 'gender': 'Male'}, |
… |
… |
arguments in the URL. All arguments requ
|
657 | 663 | |
658 | 664 | For example, suppose you have a view, ``app_views.client``, whose URLconf |
659 | 665 | takes a client ID (here, ``client()`` is a method inside the views file |
660 | | ``app_views.py``). The URLconf line might look like this:: |
| 666 | ``app_views.py``). The URLconf line might look like this: |
| 667 | |
| 668 | .. code-block:: python |
661 | 669 | |
662 | 670 | ('^client/(\d+)/$', 'app_views.client') |
663 | 671 | |
664 | 672 | If this app's URLconf is included into the project's URLconf under a path |
665 | | such as this:: |
| 673 | such as this: |
| 674 | |
| 675 | .. code-block:: python |
666 | 676 | |
667 | 677 | ('^clients/', include('project_name.app_name.urls')) |
668 | 678 | |
… |
… |
Note that if the URL you're reversing do
|
682 | 692 | :exc:`NoReverseMatch` exception raised, which will cause your site to display an |
683 | 693 | error page. |
684 | 694 | |
685 | | **New in development verson:** If you'd like to retrieve a URL without displaying it, |
686 | | you can use a slightly different call: |
| 695 | .. versionadded:: 1.0 |
687 | 696 | |
688 | | .. code-block:: html+django |
| 697 | If you'd like to retrieve a URL without displaying it, you can use a slightly |
| 698 | different call:: |
| 699 | |
689 | 700 | |
690 | 701 | {% url path.to.view arg, arg2 as the_url %} |
691 | 702 | |
692 | 703 | <a href="{{ the_url }}">I'm linking to {{ the_url }}</a> |
693 | 704 | |
694 | 705 | This ``{% url ... as var %}`` syntax will *not* cause an error if the view is |
695 | | missing. In practice you'll use this to link to views that are optional: |
696 | | |
697 | | .. code-block:: html+django |
| 706 | missing. In practice you'll use this to link to views that are optional:: |
698 | 707 | |
699 | 708 | {% url path.to.view as the_url %} |
700 | 709 | {% if the_url %} |
… |
… |
For example::
|
845 | 854 | |
846 | 855 | {{ value|dictsort:"name" }} |
847 | 856 | |
848 | | If ``value`` is:: |
| 857 | If ``value`` is: |
| 858 | |
| 859 | .. code-block:: python |
849 | 860 | |
850 | 861 | [ |
851 | 862 | {'name': 'zed', 'age': 19}, |
… |
… |
If ``value`` is::
|
853 | 864 | {'name': 'joe', 'age': 31}, |
854 | 865 | ] |
855 | 866 | |
856 | | then the output would be:: |
| 867 | then the output would be: |
| 868 | |
| 869 | .. code-block:: python |
857 | 870 | |
858 | 871 | [ |
859 | 872 | {'name': 'amy', 'age': 22}, |
… |
… |
http://diveintopython.org/native_data_ty
|
1274 | 1287 | http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice |
1275 | 1288 | for an introduction. |
1276 | 1289 | |
1277 | | Example: ``{{ some_list|slice:":2" }}`` |
| 1290 | Example:: |
| 1291 | |
| 1292 | {{ some_list|slice:":2" }} |
1278 | 1293 | |
1279 | 1294 | .. templatefilter:: slugify |
1280 | 1295 | |
diff -r 07be6b6eaea0 docs/topics/forms/formsets.txt
a
|
b
|
management form inside the template. Let
|
306 | 306 | formset = ArticleFormSet() |
307 | 307 | return render_to_response('manage_articles.html', {'formset': formset}) |
308 | 308 | |
309 | | The ``manage_articles.html`` template might look like this:: |
| 309 | The ``manage_articles.html`` template might look like this: |
| 310 | |
| 311 | .. code-block:: html+django |
310 | 312 | |
311 | 313 | <form method="POST" action=""> |
312 | 314 | {{ formset.management_form }} |
… |
… |
The ``manage_articles.html`` template mi
|
318 | 320 | </form> |
319 | 321 | |
320 | 322 | However the above can be slightly shortcutted and let the formset itself deal |
321 | | with the management form:: |
| 323 | with the management form: |
| 324 | |
| 325 | .. code-block:: html+django |
322 | 326 | |
323 | 327 | <form method="POST" action=""> |
324 | 328 | <table> |
diff -r 07be6b6eaea0 docs/topics/forms/index.txt
a
|
b
|
Working with forms
|
9 | 9 | This document provides an introduction to Django's form handling features. |
10 | 10 | For a more detailed look at the forms API, see :ref:`ref-forms-api`. For |
11 | 11 | documentation of the available field types, see :ref:`ref-forms-fields`. |
| 12 | |
| 13 | .. highlightlang:: html+django |
12 | 14 | |
13 | 15 | ``django.forms`` is Django's form-handling library. |
14 | 16 | |
… |
… |
Django's database models.
|
60 | 62 | Django's database models. |
61 | 63 | |
62 | 64 | For example, consider a form used to implement "contact me" functionality on a |
63 | | personal Web site:: |
| 65 | personal Web site: |
| 66 | |
| 67 | .. code-block:: python |
64 | 68 | |
65 | 69 | from django import forms |
66 | 70 | |
… |
… |
Using a form in a view
|
82 | 86 | Using a form in a view |
83 | 87 | ---------------------- |
84 | 88 | |
85 | | The standard pattern for processing a form in a view looks like this:: |
| 89 | The standard pattern for processing a form in a view looks like this: |
| 90 | |
| 91 | .. code-block:: python |
86 | 92 | |
87 | 93 | def contact(request): |
88 | 94 | if request.method == 'POST': # If the form has been submitted... |
… |
… |
also be converted in to the relevant Pyt
|
133 | 139 | ``cc_myself`` will be a boolean value. Likewise, fields such as ``IntegerField`` |
134 | 140 | and ``FloatField`` convert values to a Python int and float respectively. |
135 | 141 | |
136 | | Extending the above example, here's how the form data could be processed:: |
| 142 | Extending the above example, here's how the form data could be processed: |
| 143 | |
| 144 | .. code-block:: python |
137 | 145 | |
138 | 146 | if form.is_valid(): |
139 | 147 | subject = form.cleaned_data['subject'] |
diff -r 07be6b6eaea0 docs/topics/http/sessions.txt
a
|
b
|
Configuring the session engine
|
36 | 36 | Configuring the session engine |
37 | 37 | ============================== |
38 | 38 | |
39 | | .. versionadded:: 1.0. |
| 39 | .. versionadded:: 1.0 |
40 | 40 | |
41 | 41 | By default, Django stores sessions in your database (using the model |
42 | 42 | ``django.contrib.sessions.models.Session``). Though this is convenient, in |
diff -r 07be6b6eaea0 docs/topics/i18n.txt
a
|
b
|
obtain) the language translations themse
|
395 | 395 | application) and English strings (from Django itself). If you want to |
396 | 396 | support a locale for your application that is not already part of |
397 | 397 | Django, you'll need to make at least a minimal translation of the Django |
398 | | core. See the relevant :ref:LocaleMiddleware note`<locale-middleware-notes>` |
| 398 | core. See the relevant :ref:`LocaleMiddleware note<locale-middleware-notes>` |
399 | 399 | for more details. |
400 | 400 | |
401 | 401 | Message files |
diff -r 07be6b6eaea0 docs/topics/templates.txt
a
|
b
|
or CheetahTemplate_, you should feel rig
|
37 | 37 | |
38 | 38 | Templates |
39 | 39 | ========= |
| 40 | |
| 41 | .. highlightlang:: html+django |
40 | 42 | |
41 | 43 | A template is simply a text file. It can generate any text-based format (HTML, |
42 | 44 | XML, CSV, etc.). |