-
From: Marc Fargas <telenieko@telenieko.com>
Date: Tue, 9 Sep 2008 15:16:29 +0000 (+0200)
Subject: And the last ones.
X-Git-Url: http://www.marcfargas.com/gitweb/?p=django.git;a=commitdiff_plain;h=docs-trunk;hp=master
And the last ones.
---
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
index b6cc850..277622b 100644
a
|
b
|
|
3 | 3 | Writing custom django-admin commands |
4 | 4 | ==================================== |
5 | 5 | |
6 | | .. versionadded:: 1.0 |
7 | | |
8 | 6 | Applications can register their own actions with ``manage.py``. For example, |
9 | 7 | you might want to add a ``manage.py`` action for a Django app that you're |
10 | 8 | distributing. |
… |
… |
The ``explode.py`` module has only one requirement -- it must define a class
|
30 | 28 | called ``Command`` that extends ``django.core.management.base.BaseCommand``. |
31 | 29 | |
32 | 30 | For more details on how to define your own commands, look at the code for the |
33 | | existing ``django-admin.py`` commands, in ``/django/core/management/commands``. |
34 | | No newline at end of file |
| 31 | existing ``django-admin.py`` commands, in ``/django/core/management/commands``. |
-
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index 9364384..63c428e 100644
a
|
b
|
|
4 | 4 | Writing custom model fields |
5 | 5 | =========================== |
6 | 6 | |
7 | | .. versionadded:: 1.0 |
8 | | |
9 | 7 | Introduction |
10 | 8 | ============ |
11 | 9 | |
-
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index e1ddefe..ab699ac 100644
a
|
b
|
will use the function's name as the filter name.
|
157 | 157 | Filters and auto-escaping |
158 | 158 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
159 | 159 | |
160 | | .. versionadded:: 1.0 |
161 | | |
162 | 160 | When writing a custom filter, give some thought to how the filter will interact |
163 | 161 | with Django's auto-escaping behavior. Note that three types of strings can be |
164 | 162 | passed around inside the template code: |
… |
… |
without having to be parsed multiple times.
|
422 | 420 | Auto-escaping considerations |
423 | 421 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
424 | 422 | |
425 | | .. versionadded:: 1.0 |
426 | | |
427 | 423 | The output from template tags is **not** automatically run through the |
428 | 424 | auto-escaping filters. However, there are still a couple of things you should |
429 | 425 | keep in mind when writing a template tag. |
… |
… |
Now your tag should begin to look like this::
|
525 | 521 | |
526 | 522 | You also have to change the renderer to retrieve the actual contents of the |
527 | 523 | ``date_updated`` property of the ``blog_entry`` object. This can be |
528 | | accomplished by using the ``resolve_variable()`` function in |
529 | | ``django.template``. You pass ``resolve_variable()`` the variable name and the |
530 | | current context, available in the ``render`` method:: |
| 524 | accomplished by using the ``Variable()`` class in ``django.template``. |
| 525 | |
| 526 | To use the ``Variable`` class, simply instantiate it with the name of the |
| 527 | variable to be resolved, and then call ``variable.resolve(context)``. So, |
| 528 | for example:: |
531 | 529 | |
532 | | from django import template |
533 | | from django.template import resolve_variable |
534 | | import datetime |
535 | 530 | class FormatTimeNode(template.Node): |
536 | 531 | def __init__(self, date_to_be_formatted, format_string): |
537 | | self.date_to_be_formatted = date_to_be_formatted |
| 532 | self.date_to_be_formatted = Variable(date_to_be_formatted) |
538 | 533 | self.format_string = format_string |
539 | 534 | |
540 | 535 | def render(self, context): |
541 | 536 | try: |
542 | | actual_date = resolve_variable(self.date_to_be_formatted, context) |
| 537 | actual_date = self.date_to_be_formatted.resolve(context) |
543 | 538 | return actual_date.strftime(self.format_string) |
544 | 539 | except template.VariableDoesNotExist: |
545 | 540 | return '' |
546 | 541 | |
547 | | ``resolve_variable`` will try to resolve ``blog_entry.date_updated`` and then |
548 | | format it accordingly. |
549 | | |
550 | | .. versionadded:: 1.0 |
551 | | |
552 | | Variable resolution has changed in the development version of Django. |
553 | | ``template.resolve_variable()`` is still available, but has been deprecated |
554 | | in favor of a new ``template.Variable`` class. Using this class will usually |
555 | | be more efficient than calling ``template.resolve_variable`` |
556 | | |
557 | | To use the ``Variable`` class, simply instantiate it with the name of the |
558 | | variable to be resolved, and then call ``variable.resolve(context)``. So, |
559 | | in the development version, the above example would be more correctly |
560 | | written as: |
561 | | |
562 | | .. parsed-literal:: |
563 | | |
564 | | class FormatTimeNode(template.Node): |
565 | | def __init__(self, date_to_be_formatted, format_string): |
566 | | self.date_to_be_formatted = **Variable(date_to_be_formatted)** |
567 | | self.format_string = format_string |
568 | | |
569 | | def render(self, context): |
570 | | try: |
571 | | actual_date = **self.date_to_be_formatted.resolve(context)** |
572 | | return actual_date.strftime(self.format_string) |
573 | | except template.VariableDoesNotExist: |
574 | | return '' |
575 | | |
576 | | Changes are highlighted in bold. |
577 | | |
578 | 542 | Variable resolution will throw a ``VariableDoesNotExist`` exception if it cannot |
579 | 543 | resolve the string passed to it in the current context of the page. |
580 | 544 | |
-
diff --git a/docs/howto/deployment/modpython.txt b/docs/howto/deployment/modpython.txt
index 7612b40..cac6565 100644
a
|
b
|
This tells Apache: "Use mod_python for any URL at or under '/mysite/', using the
|
49 | 49 | Django mod_python handler." It passes the value of :ref:`DJANGO_SETTINGS_MODULE |
50 | 50 | <django-settings-module>` so mod_python knows which settings to use. |
51 | 51 | |
52 | | .. versionadded:: 1.0 |
53 | | The ``PythonOption django.root ...`` is new in this version. |
54 | | |
55 | 52 | Because mod_python does not know we are |
56 | 53 | serving this site from underneath the ``/mysite/`` prefix, this value needs to |
57 | 54 | be passed through to the mod_python handler in Django, via the ``PythonOption |
-
diff --git a/docs/internals/contributing.txt b/docs/internals/contributing.txt
index 52b52d6..eda463a 100644
a
|
b
|
General improvements, or other changes to the APIs that should be emphasised
|
605 | 605 | should use the ".. versionchanged:: X.Y" directive (with the same format as the |
606 | 606 | ``versionadded`` mentioned above. |
607 | 607 | |
| 608 | In case you doubt about which version to write on the note just leave it as "X.Y", |
| 609 | or the version currently being developed. The person commiting your change will |
| 610 | make sure it has the proper version number. |
| 611 | |
608 | 612 | Guidelines for ReST files |
609 | 613 | ------------------------- |
610 | 614 | |
-
diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt
index f1c3a1b..46a81a0 100644
a
|
b
|
Django comes with an optional "flatpages" application. It lets you store simple
|
11 | 11 | "flat" HTML content in a database and handles the management for you via |
12 | 12 | Django's admin interface and a Python API. |
13 | 13 | |
14 | | A flatpage is a simple object with a URL, title and content. Use it for |
| 14 | A flatpage is a simple object with a URL, title an optional content. Use it for |
15 | 15 | one-off, special-case pages, such as "About" or "Privacy Policy" pages, that |
16 | 16 | you want to store in a database but for which you don't want to develop a |
17 | 17 | custom Django application. |
… |
… |
custom Django application.
|
19 | 19 | A flatpage can use a custom template or a default, systemwide flatpage |
20 | 20 | template. It can be associated with one, or multiple, sites. |
21 | 21 | |
22 | | .. versionadded:: 1.0 |
23 | | |
24 | | The content field may optionally be left blank if you prefer to put your |
25 | | content in a custom template. |
26 | | |
27 | 22 | Here are some examples of flatpages on Django-powered sites: |
28 | 23 | |
29 | 24 | * http://www.chicagocrime.org/about/ |
-
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index cf57e79..9400d87 100644
a
|
b
|
Form wizard
|
7 | 7 | .. module:: django.contrib.formtools.wizard |
8 | 8 | :synopsis: Splits forms across multiple Web pages. |
9 | 9 | |
10 | | .. versionadded:: 1.0 |
11 | | |
12 | 10 | Django comes with an optional "form wizard" application that splits |
13 | 11 | :ref:`forms <topics-forms-index>` across multiple Web pages. It maintains |
14 | 12 | state in hashed HTML :samp:`<input type="hidden">` fields, and the data isn't |
-
diff --git a/docs/ref/contrib/humanize.txt b/docs/ref/contrib/humanize.txt
index 07a62a7..41297b6 100644
a
|
b
|
You can pass in either an integer or a string representation of an integer.
|
74 | 74 | naturalday |
75 | 75 | ---------- |
76 | 76 | |
77 | | .. versionadded:: 1.0 |
78 | | |
79 | 77 | For dates that are the current day or within one day, return "today", |
80 | 78 | "tomorrow" or "yesterday", as appropriate. Otherwise, format the date using |
81 | 79 | the passed in format string. |
-
diff --git a/docs/ref/contrib/index.txt b/docs/ref/contrib/index.txt
index 82a8955..3d58191 100644
a
|
b
|
See :ref:`topics-auth`.
|
59 | 59 | comments |
60 | 60 | ======== |
61 | 61 | |
62 | | .. versionchanged:: 1.0 |
63 | | The comments application has been rewriten. See :ref:`ref-contrib-comments-upgrade` |
64 | | for information on howto upgrade. |
65 | | |
66 | 62 | A simple yet flexible comments system. See :ref:`ref-contrib-comments-index`. |
67 | 63 | |
68 | 64 | contenttypes |
-
diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt
index bdfb77c..b4e2797 100644
a
|
b
|
each time you call ``save()``.
|
342 | 342 | Pinging Google via `manage.py` |
343 | 343 | ------------------------------ |
344 | 344 | |
345 | | .. versionadded:: 1.0 |
346 | | |
347 | 345 | Once the sitemaps application is added to your project, you may also |
348 | 346 | ping the Google server's through the command line manage.py interface:: |
349 | 347 | |
-
diff --git a/docs/ref/contrib/sites.txt b/docs/ref/contrib/sites.txt
index 28c8f4d..20823d5 100644
a
|
b
|
To do this, you can use the sites framework. A simple example::
|
230 | 230 | Caching the current ``Site`` object |
231 | 231 | =================================== |
232 | 232 | |
233 | | .. versionadded:: 1.0 |
234 | | |
235 | 233 | As the current site is stored in the database, each call to |
236 | 234 | ``Site.objects.get_current()`` could result in a database query. But Django is a |
237 | 235 | little cleverer than that: on the first request, the current site is cached, and |
… |
… |
Here's how Django uses the sites framework:
|
379 | 377 | |
380 | 378 | .. _requestsite-objects: |
381 | 379 | |
382 | | .. versionadded:: 1.0 |
383 | | |
384 | 380 | Some :ref:`django.contrib <ref-contrib-index>` applications take advantage of |
385 | 381 | the sites framework but are architected in a way that doesn't *require* the |
386 | 382 | sites framework to be installed in your database. (Some people don't want to, or |
-
diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt
index a2ee621..4cb9fb1 100644
a
|
b
|
request to the URL :file:`/rss/beats/0613/`:
|
265 | 265 | :exc:`ObjectDoesNotExist` in :meth:`get_object()` tells Django to produce |
266 | 266 | a 404 error for that request. |
267 | 267 | |
268 | | .. versionadded:: 1.0 |
269 | | meth:`get_object()` can handle the :file:`/rss/beats/` url. |
270 | | |
271 | 268 | The :meth:`get_object()` method also has a chance to handle the |
272 | 269 | :file:`/rss/beats/` url. In this case, :data:`bits` will be an |
273 | 270 | empty list. In our example, ``len(bits) != 1`` and an |
-
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 28651a5..0b4fe83 100644
a
|
b
|
many-to-many table would be stored in the ``indexes`` tablespace. The ``data``
|
360 | 360 | field would also generate an index, but no tablespace for it is specified, so |
361 | 361 | it would be stored in the model tablespace ``tables`` by default. |
362 | 362 | |
363 | | .. versionadded:: 1.0 |
364 | | |
365 | 363 | Use the :setting:`DEFAULT_TABLESPACE` and :setting:`DEFAULT_INDEX_TABLESPACE` |
366 | 364 | settings to specify default values for the db_tablespace options. |
367 | 365 | These are useful for setting a tablespace for the built-in Django apps and |
-
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 9f25b10..98f44c5 100644
a
|
b
|
Available subcommands
|
98 | 98 | cleanup |
99 | 99 | ------- |
100 | 100 | |
101 | | .. versionadded:: 1.0 |
102 | | |
103 | 101 | Can be run as a cronjob or directly to clean out old data from the database |
104 | 102 | (only expired sessions at the moment). |
105 | 103 | |
106 | 104 | compilemessages |
107 | 105 | --------------- |
108 | 106 | |
109 | | .. versionchanged:: 1.0 |
110 | | Before 1.0 this was the "bin/compile-messages.py" command. |
111 | | |
112 | 107 | Compiles .po files created with ``makemessages`` to .mo files for use with |
113 | 108 | the builtin gettext support. See :ref:`topics-i18n`. |
114 | 109 | |
… |
… |
createsuperuser
|
135 | 130 | |
136 | 131 | .. django-admin:: createsuperuser |
137 | 132 | |
138 | | .. versionadded:: 1.0 |
139 | | |
140 | 133 | Creates a superuser account (a user who has all permissions). This is |
141 | 134 | useful if you need to create an initial superuser account but did not |
142 | 135 | do so during ``syncdb``, or if you need to programmatically generate |
… |
… |
objects will be dumped.
|
210 | 203 | |
211 | 204 | .. django-admin-option:: --exclude |
212 | 205 | |
213 | | .. versionadded:: 1.0 |
214 | | |
215 | 206 | Exclude a specific application from the applications whose contents is |
216 | 207 | output. For example, to specifically exclude the `auth` application from |
217 | 208 | the output, you would call:: |
… |
… |
Example usage::
|
384 | 375 | makemessages |
385 | 376 | ------------ |
386 | 377 | |
387 | | .. versionchanged:: 1.0 |
388 | | Before 1.0 this was the ``bin/make-messages.py`` command. |
389 | | |
390 | 378 | Runs over the entire source tree of the current directory and pulls out all |
391 | 379 | strings marked for translation. It creates (or updates) a message file in the |
392 | 380 | conf/locale (in the django tree) or locale (for project and application) |
… |
… |
Example usage::
|
736 | 724 | testserver <fixture fixture ...> |
737 | 725 | -------------------------------- |
738 | 726 | |
739 | | .. versionadded:: 1.0 |
740 | | |
741 | 727 | Runs a Django development server (as in ``runserver``) using data from the |
742 | 728 | given fixture(s). |
743 | 729 | |
-
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index 72dfcb6..92e911a 100644
a
|
b
|
object::
|
157 | 157 | >>> f.cleaned_data |
158 | 158 | {'cc_myself': True, 'message': u'Hi there', 'sender': u'foo@example.com', 'subject': u'hello'} |
159 | 159 | |
160 | | .. versionchanged:: 1.0 |
161 | | The ``cleaned_data`` attribute was called ``clean_data`` in earlier releases. |
162 | | |
163 | 160 | Note that any text-based field -- such as ``CharField`` or ``EmailField`` -- |
164 | 161 | always cleans the input into a Unicode string. We'll cover the encoding |
165 | 162 | implications later in this document. |
… |
… |
when printed::
|
563 | 560 | Binding uploaded files to a form |
564 | 561 | -------------------------------- |
565 | 562 | |
566 | | .. versionadded:: 1.0 |
567 | | |
568 | 563 | Dealing with forms that have ``FileField`` and ``ImageField`` fields |
569 | 564 | is a little more complicated than a normal form. |
570 | 565 | |
-
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 0656c32..5d6b3fd 100644
a
|
b
|
fields. We've specified ``auto_id=False`` to simplify the output::
|
219 | 219 | ``error_messages`` |
220 | 220 | ~~~~~~~~~~~~~~~~~~ |
221 | 221 | |
222 | | .. versionadded:: 1.0 |
223 | | |
224 | 222 | .. attribute:: Field.error_messages |
225 | 223 | |
226 | 224 | |
… |
… |
For each field, we describe the default widget used if you don't specify
|
315 | 313 | the field has ``required=True``. |
316 | 314 | * Error message keys: ``required`` |
317 | 315 | |
318 | | .. versionchanged:: 1.0 |
319 | | The empty value for a ``CheckboxInput`` (and hence the standard ``BooleanField``) |
320 | | has changed to return ``False`` instead of ``None`` in the development version. |
321 | | |
322 | 316 | .. note:: |
323 | 317 | |
324 | 318 | Since all ``Field`` subclasses have ``required=True`` by default, the |
… |
… |
If no ``input_formats`` argument is provided, the default input formats are::
|
449 | 443 | '%m/%d/%y %H:%M', # '10/25/06 14:30' |
450 | 444 | '%m/%d/%y', # '10/25/06' |
451 | 445 | |
452 | | .. versionchanged:: 1.0 |
453 | | The ``DateTimeField`` used to use a ``TextInput`` widget by default. This has now changed. |
454 | | |
455 | 446 | ``DecimalField`` |
456 | 447 | ~~~~~~~~~~~~~~~~ |
457 | 448 | |
458 | | .. versionadded:: 1.0 |
459 | | |
460 | 449 | .. class:: DecimalField(**kwargs) |
461 | 450 | |
462 | 451 | * Default widget: ``TextInput`` |
… |
… |
given length.
|
504 | 493 | ``FileField`` |
505 | 494 | ~~~~~~~~~~~~~ |
506 | 495 | |
507 | | .. versionadded:: 1.0 |
508 | | |
509 | 496 | .. class:: FileField(**kwargs) |
510 | 497 | |
511 | 498 | * Default widget: ``FileInput`` |
… |
… |
When you use a ``FileField`` in a form, you must also remember to
|
524 | 511 | ``FilePathField`` |
525 | 512 | ~~~~~~~~~~~~~~~~~ |
526 | 513 | |
527 | | .. versionadded:: 1.0 |
528 | | |
529 | 514 | .. class:: FilePathField(**kwargs) |
530 | 515 | |
531 | 516 | * Default widget: ``Select`` |
… |
… |
These control the range of values permitted in the field.
|
570 | 555 | ``ImageField`` |
571 | 556 | ~~~~~~~~~~~~~~ |
572 | 557 | |
573 | | .. versionadded:: 1.0 |
574 | | |
575 | 558 | .. class:: ImageField(**kwargs) |
576 | 559 | |
577 | 560 | * Default widget: ``FileInput`` |
-
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index c9cc292..e9a55c9 100644
a
|
b
|
commonly used groups of widgets:
|
38 | 38 | |
39 | 39 | .. class:: DateTimeInput |
40 | 40 | |
41 | | .. versionadded:: 1.0 |
42 | | |
43 | 41 | Date/time input as a simple text box: ``<input type='text' ...>`` |
44 | 42 | |
45 | 43 | .. class:: Textarea |
-
diff --git a/docs/ref/generic-views.txt b/docs/ref/generic-views.txt
index f92674e..b78feb4 100644
a
|
b
|
a date in the *future* are not included unless you set ``allow_future`` to
|
198 | 198 | specified in ``date_field`` is greater than the current date/time. By |
199 | 199 | default, this is ``False``. |
200 | 200 | |
201 | | .. versionadded:: 1.0 |
202 | | |
203 | 201 | * ``template_object_name``: Designates the name of the template variable |
204 | 202 | to use in the template context. By default, this is ``'latest'``. |
205 | 203 | |
… |
… |
In addition to ``extra_context``, the template's context will be:
|
224 | 222 | ordered in reverse. This is equivalent to |
225 | 223 | ``queryset.dates(date_field, 'year')[::-1]``. |
226 | 224 | |
227 | | .. versionchanged:: 1.0 |
228 | | The behaviour depending on ``template_object_name`` is new in this version. |
229 | | |
230 | 225 | * ``latest``: The ``num_latest`` objects in the system, ordered descending |
231 | 226 | by ``date_field``. For example, if ``num_latest`` is ``10``, then |
232 | 227 | ``latest`` will be a list of the latest 10 objects in ``queryset``. |
… |
… |
If ``template_name`` isn't specified, this view will use the template
|
736 | 731 | |
737 | 732 | **Template context:** |
738 | 733 | |
739 | | .. versionadded:: 1.0 |
740 | | The ``paginator`` and ``page_obj`` context variables are new. |
741 | | |
742 | 734 | In addition to ``extra_context``, the template's context will be: |
743 | 735 | |
744 | 736 | * ``object_list``: The list of objects. This variable's name depends on the |
… |
… |
represented as page ``1``.
|
782 | 774 | For more on pagination, read the :ref:`pagination documentation |
783 | 775 | <topics-pagination>`. |
784 | 776 | |
785 | | .. versionadded:: 1.0 |
786 | | |
787 | 777 | As a special case, you are also permitted to use ``last`` as a value for |
788 | 778 | ``page``:: |
789 | 779 | |
… |
… |
Create/update/delete generic views
|
868 | 858 | The ``django.views.generic.create_update`` module contains a set of functions |
869 | 859 | for creating, editing and deleting objects. |
870 | 860 | |
871 | | .. versionchanged:: 1.0 |
872 | | |
873 | | ``django.views.generic.create_update.create_object`` and |
874 | | ``django.views.generic.create_update.update_object`` now use the new :ref:`forms |
875 | | library <topics-forms-index>` to build and display the form. |
876 | | |
877 | 861 | ``django.views.generic.create_update.create_object`` |
878 | 862 | ---------------------------------------------------- |
879 | 863 | |
-
diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt
index e47accc..40ee983 100644
a
|
b
|
Adds a few conveniences for perfectionists:
|
54 | 54 | don't have a valid URL pattern for ``foo.com/bar`` but *do* have a valid |
55 | 55 | pattern for ``foo.com/bar/``. |
56 | 56 | |
57 | | .. versionchanged:: 1.0 |
58 | | The behavior of :setting:`APPEND_SLASH` has changed slightly in this |
59 | | version. It didn't used to check whether the pattern was matched in |
60 | | the URLconf. |
61 | | |
62 | 57 | If :setting:`PREPEND_WWW` is ``True``, URLs that lack a leading "www." |
63 | 58 | will be redirected to the same URL with a leading "www." |
64 | 59 | |
… |
… |
CSRF protection middleware
|
175 | 170 | |
176 | 171 | .. class:: django.contrib.csrf.middleware.CsrfMiddleware |
177 | 172 | |
178 | | .. versionadded:: 1.0 |
179 | | |
180 | 173 | Adds protection against Cross Site Request Forgeries by adding hidden form |
181 | 174 | fields to POST forms and checking requests for the correct value. See the |
182 | 175 | :ref:`Cross Site Request Forgery protection documentation <ref-contrib-csrf>`. |
-
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 9c5fd23..a32de04 100644
a
|
b
|
If ``True``, djadmin:`django-admin.py sqlindexes <sqlindexes>` will output a
|
171 | 171 | |
172 | 172 | .. attribute:: Field.db_tablespace |
173 | 173 | |
174 | | .. versionadded:: 1.0 |
175 | | |
176 | 174 | The name of the database tablespace to use for this field's index, if this field |
177 | 175 | is indexed. The default is the project's :setting:`DEFAULT_INDEX_TABLESPACE` |
178 | 176 | setting, if set, or the :attr:`~Field.db_tablespace` of the model, if any. If |
… |
… |
shortcuts.
|
379 | 377 | ``DecimalField`` |
380 | 378 | ---------------- |
381 | 379 | |
382 | | .. versionadded:: 1.0 |
383 | | |
384 | 380 | .. class:: DecimalField(max_digits=None, decimal_places=None, [**options]) |
385 | 381 | |
386 | 382 | A fixed-precision decimal number, represented in Python by a |
… |
… |
A file-upload field. Has one **required** argument:
|
435 | 431 | date/time of the file upload (so that uploaded files don't fill up the given |
436 | 432 | directory). |
437 | 433 | |
438 | | .. versionchanged:: 1.0 |
439 | | |
440 | 434 | This may also be a callable, such as a function, which will be called to |
441 | 435 | obtain the upload path, including the filename. This callable must be able |
442 | 436 | to accept two arguments, and return a Unix-style path (with forward slashes) |
… |
… |
Also has one optional argument:
|
465 | 459 | |
466 | 460 | .. attribute:: FileField.storage |
467 | 461 | |
468 | | .. versionadded:: 1.0 |
469 | | |
470 | 462 | Optional. A storage object, which handles the storage and retrieval of your |
471 | 463 | files. See :ref:`topics-files` for details on how to provide this object. |
472 | 464 | |
… |
… |
without validation, to a directory that's within your Web server's document
|
513 | 505 | root, then somebody could upload a CGI or PHP script and execute that script by |
514 | 506 | visiting its URL on your site. Don't allow that. |
515 | 507 | |
516 | | .. versionadded:: 1.0 |
517 | | The ``max_length`` argument was added in this version. |
518 | | |
519 | 508 | By default, :class:`FileField` instances are |
520 | 509 | created as ``varchar(100)`` columns in your database. As with other fields, you |
521 | 510 | can change the maximum length using the :attr:`~CharField.max_length` argument. |
… |
… |
base filename, not the full path. So, this example::
|
559 | 548 | because the :attr:`~FilePathField.match` applies to the base filename |
560 | 549 | (``foo.gif`` and ``bar.gif``). |
561 | 550 | |
562 | | .. versionadded:: 1.0 |
563 | | The ``max_length`` argument was added in this version. |
564 | | |
565 | 551 | By default, :class:`FilePathField` instances are |
566 | 552 | created as ``varchar(100)`` columns in your database. As with other fields, you |
567 | 553 | can change the maximum length using the :attr:`~CharField.max_length` argument. |
… |
… |
can change the maximum length using the :attr:`~CharField.max_length` argument.
|
571 | 557 | |
572 | 558 | .. class:: FloatField([**options]) |
573 | 559 | |
574 | | .. versionchanged:: 1.0 |
575 | | |
576 | 560 | A floating-point number represented in Python by a ``float`` instance. |
577 | 561 | |
578 | 562 | The admin represents this as an ``<input type="text">`` (a single-line input). |
… |
… |
Requires the `Python Imaging Library`_.
|
608 | 592 | |
609 | 593 | .. _Python Imaging Library: http://www.pythonware.com/products/pil/ |
610 | 594 | |
611 | | .. versionadded:: 1.0 |
612 | | The ``max_length`` argument was added in this version. |
613 | | |
614 | 595 | By default, :class:`ImageField` instances are |
615 | 596 | created as ``varchar(100)`` columns in your database. As with other fields, you |
616 | 597 | can change the maximum length using the :attr:`~CharField.max_length` argument. |
… |
… |
Note, however, that this only refers to models in the same ``models.py`` file --
|
776 | 757 | you cannot use a string to reference a model defined in another application or |
777 | 758 | imported from elsewhere. |
778 | 759 | |
779 | | .. versionchanged:: 1.0 |
780 | | Refering models in other applications must include the application label. |
781 | | |
782 | 760 | To refer to models defined in another |
783 | 761 | application, you must instead explicitly specify the application label. For |
784 | 762 | example, if the ``Manufacturer`` model above is defined in another application |
-
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index c7ea4f3..9c6e0f2 100644
a
|
b
|
To save an object back to the database, call ``save()``:
|
35 | 35 | |
36 | 36 | Of course, there are some subtleties; see the sections below. |
37 | 37 | |
38 | | .. versionadded:: 1.0 |
39 | | |
40 | | The signature of the ``save()`` method has changed from earlier versions |
41 | | (``force_insert`` and ``force_update`` have been added). If you are overriding |
42 | | these methods, be sure to use the correct signature. |
43 | | |
44 | 38 | Auto-incrementing primary keys |
45 | 39 | ------------------------------ |
46 | 40 | |
… |
… |
documentation for ``AutoField`` for more details.
|
63 | 57 | The ``pk`` property |
64 | 58 | ~~~~~~~~~~~~~~~~~~~ |
65 | 59 | |
66 | | .. versionadded:: 1.0 |
67 | | |
68 | 60 | .. attribute:: Model.pk |
69 | 61 | |
70 | 62 | Regardless of whether you define a primary key field yourself, or let Django |
… |
… |
auto-primary-key values`_ above and `Forcing an INSERT or UPDATE`_ below.
|
173 | 165 | Forcing an INSERT or UPDATE |
174 | 166 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
175 | 167 | |
176 | | .. versionadded:: 1.0 |
177 | | |
178 | 168 | In some rare circumstances, it's necessary to be able to force the ``save()`` |
179 | 169 | method to perform an SQL ``INSERT`` and not fall back to doing an ``UPDATE``. |
180 | 170 | Or vice-versa: update, if possible, but not insert a new row. In these cases |
-
diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt
index e4e2d38..8e5f39b 100644
a
|
b
|
Django quotes column and table names behind the scenes.
|
55 | 55 | |
56 | 56 | .. attribute:: Options.db_tablespace |
57 | 57 | |
58 | | .. versionadded:: 1.0 |
59 | | |
60 | 58 | The name of the database tablespace to use for the model. If the backend doesn't |
61 | 59 | support tablespaces, this option is ignored. |
62 | 60 | |
… |
… |
It's used in the Django admin and is enforced at the database level (i.e., the
|
152 | 150 | appropriate ``UNIQUE`` statements are included in the ``CREATE TABLE`` |
153 | 151 | statement). |
154 | 152 | |
155 | | .. versionadded:: 1.0 |
156 | | |
157 | 153 | For convenience, unique_together can be a single list when dealing with a single |
158 | 154 | set of fields:: |
159 | 155 | |
-
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 68b69b6..010b683 100644
a
|
b
|
ordering piece of data for each of the main items you are selecting, the
|
176 | 176 | ordering may well be exactly what you want to do. Use ordering on multi-valued |
177 | 177 | fields with care and make sure the results are what you expect. |
178 | 178 | |
179 | | .. versionadded:: 1.0 |
180 | | |
181 | 179 | If you don't want any ordering to be applied to a query, not even the default |
182 | 180 | ordering, call ``order_by()`` with no parameters. |
183 | 181 | |
184 | | .. versionadded:: 1.0 |
185 | | |
186 | 182 | The syntax for ordering across related models has changed. See the `Django 0.96 |
187 | 183 | documentation`_ for the old behaviour. |
188 | 184 | |
… |
… |
A couple of subtleties that are worth mentioning:
|
290 | 286 | |
291 | 287 | >>> Entry.objects.values('blog_id') |
292 | 288 | [{'blog_id': 1}, ...] |
| 289 | |
293 | 290 | * When using ``values()`` together with ``distinct()``, be aware that |
294 | 291 | ordering can affect the results. See the note in the `distinct()`_ |
295 | 292 | section, above, for details. |
296 | 293 | |
297 | | .. versionadded:: 1.0 |
298 | | |
299 | | Previously, it was not possible to pass ``blog_id`` to ``values()`` in the above |
300 | | example, only ``blog``. |
301 | | |
302 | 294 | A ``ValuesQuerySet`` is useful when you know you're only going to need values |
303 | 295 | from a small number of the available fields and you won't need the |
304 | 296 | functionality of a model instance object. It's more efficient to select only |
… |
… |
individualism.
|
319 | 311 | ``values_list(*fields)`` |
320 | 312 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
321 | 313 | |
322 | | .. versionadded:: 1.0 |
323 | | |
324 | 314 | This is similar to ``values()`` except that instead of returning a list of |
325 | 315 | dictionaries, it returns a list of tuples. Each tuple contains the value from |
326 | 316 | the respective field passed into the ``values_list()`` call -- so the first |
… |
… |
Examples::
|
381 | 371 | ``none()`` |
382 | 372 | ~~~~~~~~~~ |
383 | 373 | |
384 | | .. versionadded:: 1.0 |
385 | | |
386 | 374 | Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to |
387 | 375 | an empty list. This can be used in cases where you know that you should |
388 | 376 | return an empty result set and your caller is expecting a ``QuerySet`` |
… |
… |
follow::
|
463 | 451 | p = b.author # Doesn't hit the database. |
464 | 452 | c = p.hometown # Requires a database call. |
465 | 453 | |
466 | | .. versionadded:: 1.0 |
467 | | |
468 | | The ``depth`` argument is new in Django version 1.0. |
469 | | |
470 | 454 | ``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)`` |
471 | 455 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
472 | 456 | |
… |
… |
of the arguments is required, but you should use at least one of them.
|
525 | 509 | some database backends, such as some MySQL versions, don't support |
526 | 510 | subqueries. |
527 | 511 | |
528 | | .. versionadded:: 1.0 |
529 | | |
530 | 512 | In some rare cases, you might wish to pass parameters to the SQL fragments |
531 | 513 | in ``extra(select=...)```. For this purpose, use the ``select_params`` |
532 | 514 | parameter. Since ``select_params`` is a sequence and the ``select`` |
… |
… |
SQL equivalents::
|
857 | 839 | SELECT ... WHERE id = 14; |
858 | 840 | SELECT ... WHERE id IS NULL; |
859 | 841 | |
860 | | .. versionchanged:: 1.0 |
861 | | The semantics of ``id__exact=None`` have |
862 | | changed in the development version. Previously, it was (intentionally) |
863 | | converted to ``WHERE id = NULL`` at the SQL level, which would never match |
864 | | anything. It has now been changed to behave the same as ``id__isnull=True``. |
865 | | |
866 | 842 | .. admonition:: MySQL comparisons |
867 | 843 | |
868 | 844 | In MySQL, whether or not ``exact`` comparisons are case-insensitive by |
… |
… |
database to add the full-text index.
|
1139 | 1115 | regex |
1140 | 1116 | ~~~~~ |
1141 | 1117 | |
1142 | | .. versionadded:: 1.0 |
1143 | | |
1144 | 1118 | Case-sensitive regular expression match. |
1145 | 1119 | |
1146 | 1120 | The regular expression syntax is that of the database backend in use. In the |
… |
… |
regular expression syntax is recommended.
|
1167 | 1141 | iregex |
1168 | 1142 | ~~~~~~ |
1169 | 1143 | |
1170 | | .. versionadded:: 1.0 |
1171 | | |
1172 | 1144 | Case-insensitive regular expression match. |
1173 | 1145 | |
1174 | 1146 | Example:: |
-
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index 89e5195..2805280 100644
a
|
b
|
All attributes except ``session`` should be considered read-only.
|
49 | 49 | |
50 | 50 | .. attribute:: HttpRequest.encoding |
51 | 51 | |
52 | | .. versionadded:: 1.0 |
53 | | |
54 | 52 | A string representing the current encoding used to decode form submission |
55 | 53 | data (or ``None``, which means the ``DEFAULT_CHARSET`` setting is used). |
56 | 54 | You can write to this attribute to change the encoding used when accessing |
… |
… |
All attributes except ``session`` should be considered read-only.
|
112 | 110 | ``enctype="multipart/form-data"``. Otherwise, ``FILES`` will be a blank |
113 | 111 | dictionary-like object. |
114 | 112 | |
115 | | .. versionchanged:: 1.0 |
116 | | |
117 | 113 | In previous versions of Django, ``request.FILES`` contained simple ``dict`` |
118 | 114 | objects representing uploaded files. This is no longer true -- files are |
119 | 115 | represented by ``UploadedFile`` objects as described below. |
… |
… |
Methods
|
182 | 178 | |
183 | 179 | .. method:: HttpRequest.get_host() |
184 | 180 | |
185 | | .. versionadded:: 1.0 |
186 | | |
187 | 181 | Returns the originating host of the request using information from the |
188 | 182 | ``HTTP_X_FORWARDED_HOST`` and ``HTTP_HOST`` headers (in that order). If |
189 | 183 | they don't provide a value, the method uses a combination of |
… |
… |
Methods
|
201 | 195 | |
202 | 196 | .. method:: HttpRequest.build_absolute_uri(location) |
203 | 197 | |
204 | | .. versionadded:: 1.0 |
205 | | |
206 | 198 | Returns the absolute URI form of ``location``. If no location is provided, |
207 | 199 | the location will be set to ``request.get_full_path()``. |
208 | 200 | |
… |
… |
Methods
|
219 | 211 | |
220 | 212 | .. method:: HttpRequest.is_ajax() |
221 | 213 | |
222 | | .. versionadded:: 1.0 |
223 | | |
224 | 214 | Returns ``True`` if the request was made via an ``XMLHttpRequest``, by checking |
225 | 215 | the ``HTTP_X_REQUESTED_WITH`` header for the string ``'XMLHttpRequest'``. The |
226 | 216 | following major JavaScript libraries all send this header: |
… |
… |
In addition, ``QueryDict`` has the following methods:
|
348 | 338 | |
349 | 339 | .. method:: QueryDict.lists() |
350 | 340 | |
351 | | Like :method:items(), except it includes all values, as a list, for each |
| 341 | Like :meth:`items()`, except it includes all values, as a list, for each |
352 | 342 | member of the dictionary. For example:: |
353 | 343 | |
354 | 344 | >>> q = QueryDict('a=1&a=2&a=3') |
… |
… |
Methods
|
447 | 437 | |
448 | 438 | ``status`` is the `HTTP Status code`_ for the response. |
449 | 439 | |
450 | | .. versionadded:: 1.0 |
451 | | |
452 | 440 | ``content_type`` is an alias for ``mimetype``. Historically, this parameter |
453 | 441 | was only called ``mimetype``, but since this is actually the value included |
454 | 442 | in the HTTP ``Content-Type`` header, it can also include the character set |
… |
… |
types of HTTP responses. Like ``HttpResponse``, these subclasses live in
|
549 | 537 | |
550 | 538 | .. class:: HttpResponseBadRequest |
551 | 539 | |
552 | | .. versionadded:: 1.0 |
553 | | |
554 | 540 | Acts just like :class:`HttpResponse` but uses a 400 status code. |
555 | 541 | |
556 | 542 | .. class:: HttpResponseNotFound |
-
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index 3dd83eb..d2deb95 100644
a
|
b
|
Never deploy a site into production with ``DEBUG`` turned on.
|
289 | 289 | DEBUG_PROPAGATE_EXCEPTIONS |
290 | 290 | -------------------------- |
291 | 291 | |
292 | | .. versionadded:: 1.0 |
293 | | |
294 | 292 | Default: ``False`` |
295 | 293 | |
296 | 294 | If set to True, Django's normal exception handling of view functions |
… |
… |
site manager(s).
|
344 | 342 | DEFAULT_TABLESPACE |
345 | 343 | ------------------ |
346 | 344 | |
347 | | .. versionadded:: 1.0 |
348 | | |
349 | 345 | Default: ``''`` (Empty string) |
350 | 346 | |
351 | 347 | Default tablespace to use for models that don't specify one, if the |
… |
… |
backend supports it.
|
356 | 352 | DEFAULT_INDEX_TABLESPACE |
357 | 353 | ------------------------ |
358 | 354 | |
359 | | .. versionadded:: 1.0 |
360 | | |
361 | 355 | Default: ``''`` (Empty string) |
362 | 356 | |
363 | 357 | Default tablespace to use for indexes on fields that don't specify |
… |
… |
trailing space.
|
437 | 431 | EMAIL_USE_TLS |
438 | 432 | ------------- |
439 | 433 | |
440 | | .. versionadded:: 1.0 |
441 | | |
442 | 434 | Default: ``False`` |
443 | 435 | |
444 | 436 | Whether to use a TLS (secure) connection when talking to the SMTP server. |
… |
… |
Whether to use a TLS (secure) connection when talking to the SMTP server.
|
448 | 440 | FILE_CHARSET |
449 | 441 | ------------ |
450 | 442 | |
451 | | .. versionadded:: 1.0 |
452 | | |
453 | 443 | Default: ``'utf-8'`` |
454 | 444 | |
455 | 445 | The character encoding used to decode any files read from disk. This includes |
… |
… |
template files and initial SQL data files.
|
460 | 450 | FILE_UPLOAD_HANDLERS |
461 | 451 | -------------------- |
462 | 452 | |
463 | | .. versionadded:: 1.0 |
464 | | |
465 | 453 | Default:: |
466 | 454 | |
467 | 455 | ("django.core.files.uploadhandler.MemoryFileUploadHandler", |
… |
… |
A tuple of handlers to use for uploading. See :ref:`topics-files` for details.
|
474 | 462 | FILE_UPLOAD_MAX_MEMORY_SIZE |
475 | 463 | --------------------------- |
476 | 464 | |
477 | | .. versionadded:: 1.0 |
478 | | |
479 | 465 | Default: ``2621440`` (i.e. 2.5 MB). |
480 | 466 | |
481 | 467 | The maximum size (in bytes) that an upload will be before it gets streamed to |
… |
… |
the file system. See :ref:`topics-files` for details.
|
486 | 472 | FILE_UPLOAD_TEMP_DIR |
487 | 473 | -------------------- |
488 | 474 | |
489 | | .. versionadded:: 1.0 |
490 | | |
491 | 475 | Default: ``None`` |
492 | 476 | |
493 | 477 | The directory to store data temporarily while uploading files. If ``None``, |
… |
… |
standard language format. For example, U.S. English is ``"en-us"``. See
|
617 | 601 | LANGUAGE_COOKIE_NAME |
618 | 602 | -------------------- |
619 | 603 | |
620 | | .. versionadded:: 1.0 |
621 | | |
622 | 604 | Default: ``'django_language'`` |
623 | 605 | |
624 | 606 | The name of the cookie to use for the language cookie. This can be whatever you |
… |
… |
See :ref:`translations-in-your-own-projects`.
|
681 | 663 | LOGIN_REDIRECT_URL |
682 | 664 | ------------------ |
683 | 665 | |
684 | | .. versionadded:: 1.0 |
685 | | |
686 | 666 | Default: ``'/accounts/profile/'`` |
687 | 667 | |
688 | 668 | The URL where requests are redirected after login when the |
… |
… |
decorator, for example.
|
696 | 676 | LOGIN_URL |
697 | 677 | --------- |
698 | 678 | |
699 | | .. versionadded:: 1.0 |
700 | | |
701 | 679 | Default: ``'/accounts/login/'`` |
702 | 680 | |
703 | 681 | The URL where requests are redirected for login, specially when using the |
… |
… |
The URL where requests are redirected for login, specially when using the
|
708 | 686 | LOGOUT_URL |
709 | 687 | ---------- |
710 | 688 | |
711 | | .. versionadded:: 1.0 |
712 | | |
713 | 689 | Default: ``'/accounts/logout/'`` |
714 | 690 | |
715 | 691 | LOGIN_URL counterpart. |
… |
… |
The e-mail address that error messages come from, such as those sent to
|
869 | 845 | SESSION_ENGINE |
870 | 846 | -------------- |
871 | 847 | |
872 | | .. versionadded:: 1.0 |
873 | | |
874 | 848 | Default: ``django.contrib.sessions.backends.db`` |
875 | 849 | |
876 | 850 | Controls where Django stores session data. Valid values are: |
… |
… |
should be different from ``LANGUAGE_COOKIE_NAME``). See the :ref:`topics-http-se
|
916 | 890 | SESSION_COOKIE_PATH |
917 | 891 | ------------------- |
918 | 892 | |
919 | | .. versionadded:: 1.0 |
920 | | |
921 | 893 | Default: ``'/'`` |
922 | 894 | |
923 | 895 | The path set on the session cookie. This should either match the URL path of your |
… |
… |
See the :ref:`topics-http-sessions`.
|
954 | 926 | SESSION_FILE_PATH |
955 | 927 | ----------------- |
956 | 928 | |
957 | | .. versionadded:: 1.0 |
958 | | |
959 | 929 | Default: ``None`` |
960 | 930 | |
961 | 931 | If you're using file-based session storage, this sets the directory in |
… |
… |
misspelled) variables. See :ref:`invalid-template-variables`..
|
1061 | 1031 | TEST_DATABASE_CHARSET |
1062 | 1032 | --------------------- |
1063 | 1033 | |
1064 | | .. versionadded:: 1.0 |
1065 | | |
1066 | 1034 | Default: ``None`` |
1067 | 1035 | |
1068 | 1036 | The character set encoding used to create the test database. The value of this |
… |
… |
Supported for the PostgreSQL_ (``postgresql``, ``postgresql_psycopg2``) and MySQ
|
1079 | 1047 | TEST_DATABASE_COLLATION |
1080 | 1048 | ------------------------ |
1081 | 1049 | |
1082 | | .. versionadded:: 1.0 |
1083 | | |
1084 | 1050 | Default: ``None`` |
1085 | 1051 | |
1086 | 1052 | The collation order to use when creating the test database. This value is |
-
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index a220c79..df9e932 100644
a
|
b
|
See :ref:`topics-i18n` for more.
|
391 | 391 | django.core.context_processors.media |
392 | 392 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
393 | 393 | |
394 | | .. versionadded:: 1.0 |
395 | | |
396 | 394 | If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every |
397 | 395 | ``RequestContext`` will contain a variable ``MEDIA_URL``, providing the |
398 | 396 | value of the :setting:`MEDIA_URL` setting. |
-
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index a28cf4f..b3835fb 100644
a
|
b
|
Built-in tag reference
|
21 | 21 | autoescape |
22 | 22 | ~~~~~~~~~~ |
23 | 23 | |
24 | | .. versionadded:: 1.0 |
25 | | |
26 | 24 | Control the current auto-escaping behavior. This tag takes either ``on`` or |
27 | 25 | ``off`` as an argument and that determines whether auto-escaping is in effect |
28 | 26 | inside the block. |
… |
… |
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``
|
56 | 54 | cycle |
57 | 55 | ~~~~~ |
58 | 56 | |
59 | | .. versionchanged:: 1.0 |
60 | | Cycle among the given strings or variables each time this tag is encountered. |
61 | | |
62 | 57 | Within a loop, cycles among the given strings/variables each time through the |
63 | 58 | loop:: |
64 | 59 | |
… |
… |
provided in ``athlete_list``::
|
173 | 168 | |
174 | 169 | You can loop over a list in reverse by using ``{% for obj in list reversed %}``. |
175 | 170 | |
176 | | .. versionadded:: 1.0 |
177 | | |
178 | 171 | If you need to loop over a list of lists, you can unpack the values |
179 | 172 | in each sub-list into individual variables. For example, if your context |
180 | 173 | contains a list of (x,y) coordinates called ``points``, you could use the |
… |
… |
such as this:
|
682 | 675 | |
683 | 676 | The template tag will output the string ``/clients/client/123/``. |
684 | 677 | |
685 | | .. versionadded:: 1.0 |
686 | | |
687 | 678 | If you're using :ref:`named URL patterns <naming-url-patterns>`, you can |
688 | 679 | refer to the name of the pattern in the ``url`` tag instead of using the |
689 | 680 | path to the view. |
… |
… |
Note that if the URL you're reversing doesn't exist, you'll get an
|
692 | 683 | :exc:`NoReverseMatch` exception raised, which will cause your site to display an |
693 | 684 | error page. |
694 | 685 | |
695 | | .. versionadded:: 1.0 |
696 | | |
697 | 686 | If you'd like to retrieve a URL without displaying it, you can use a slightly |
698 | 687 | different call:: |
699 | 688 | |
… |
… |
which is rounded up to 88).
|
731 | 720 | with |
732 | 721 | ~~~~ |
733 | 722 | |
734 | | .. versionadded:: 1.0 |
735 | | |
736 | 723 | Caches a complex variable under a simpler name. This is useful when accessing |
737 | 724 | an "expensive" method (e.g., one that hits the database) multiple times. |
738 | 725 | |
… |
… |
applied to the result will only result in one round of escaping being done. So
|
919 | 906 | it is safe to use this function even in auto-escaping environments. If you want |
920 | 907 | multiple escaping passes to be applied, use the ``force_escape`` filter. |
921 | 908 | |
922 | | .. versionchanged:: 1.0 |
923 | | Due to auto-escaping, the behavior of this filter has changed slightly. |
924 | | The replacements are only made once, after |
925 | | all other filters are applied -- including filters before and after it. |
926 | | |
927 | 909 | .. templatefilter:: escapejs |
928 | 910 | |
929 | 911 | escapejs |
930 | 912 | ~~~~~~~~ |
931 | 913 | |
932 | | .. versionadded:: 1.0 |
933 | | |
934 | 914 | Escapes characters for use in JavaScript strings. This does *not* make the |
935 | 915 | string safe for use in HTML, but does protect you from syntax errors when using |
936 | 916 | templates to generate JavaScript/JSON. |
… |
… |
If ``value`` is the list ``['a', 'b', 'c']``, the output will be ``'a'``.
|
967 | 947 | fix_ampersands |
968 | 948 | ~~~~~~~~~~~~~~ |
969 | 949 | |
970 | | .. versionchanged:: 1.0 |
971 | | This is rarely useful as ampersands are now automatically escaped. See escape_ for more information. |
972 | | |
973 | 950 | Replaces ampersands with ``&`` entities. |
974 | 951 | |
975 | 952 | For example:: |
… |
… |
with an argument of ``-1``.
|
1025 | 1002 | force_escape |
1026 | 1003 | ~~~~~~~~~~~~ |
1027 | 1004 | |
1028 | | .. versionadded:: 1.0 |
1029 | | |
1030 | 1005 | Applies HTML escaping to a string (see the ``escape`` filter for details). |
1031 | 1006 | This filter is applied *immediately* and returns a new, escaped string. This |
1032 | 1007 | is useful in the rare cases where you need multiple escaping or want to apply |
… |
… |
If ``value`` is the list ``['a', 'b', 'c']``, the output will be the string
|
1080 | 1055 | last |
1081 | 1056 | ~~~~ |
1082 | 1057 | |
1083 | | .. versionadded:: 1.0 |
1084 | | |
1085 | 1058 | Returns the last item in a list. |
1086 | 1059 | |
1087 | 1060 | For example:: |
… |
… |
unordered_list
|
1434 | 1407 | Recursively takes a self-nested list and returns an HTML unordered list -- |
1435 | 1408 | WITHOUT opening and closing <ul> tags. |
1436 | 1409 | |
1437 | | .. versionchanged:: 1.0 |
1438 | | The format accepted by ``unordered_list`` has changed to be easier to understand. |
1439 | | |
1440 | 1410 | The list is assumed to be in the proper format. For example, if ``var`` contains |
1441 | 1411 | ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then |
1442 | 1412 | ``{{ var|unordered_list }}`` would return:: |
-
diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt
index 4976a35..16d2cc8 100644
a
|
b
|
|
4 | 4 | Unicode data in Django |
5 | 5 | ====================== |
6 | 6 | |
7 | | .. versionadded:: 1.0 |
8 | | |
9 | 7 | Django natively supports Unicode data everywhere. Providing your database can |
10 | 8 | somehow store the data, you can safely pass around Unicode strings to |
11 | 9 | templates, models and the database. |
-
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
index b6e9a9d..9d454ec 100644
a
|
b
|
Methods
|
167 | 167 | |
168 | 168 | .. method:: models.User.set_unusable_password() |
169 | 169 | |
170 | | .. versionadded:: 1.0 |
171 | | |
172 | 170 | Marks the user as having no password set. This isn't the same as having |
173 | 171 | a blank string for a password. |
174 | 172 | :meth:`~django.contrib.auth.models.User.check_password()` for this user |
… |
… |
Methods
|
180 | 178 | |
181 | 179 | .. method:: models.User.has_usable_password() |
182 | 180 | |
183 | | .. versionadded:: 1.0 |
184 | | |
185 | 181 | Returns ``False`` if |
186 | 182 | :meth:`~django.contrib.auth.models.User.set_unusable_password()` has |
187 | 183 | been called for this user. |
… |
… |
they're used by Web requests, as explained in the next section.
|
365 | 361 | Creating superusers |
366 | 362 | ------------------- |
367 | 363 | |
368 | | .. versionadded:: 1.0 |
369 | | The ``manage.py createsuperuser`` command is new. |
370 | | |
371 | 364 | :djadmin:`manage.py syncdb <syncdb>` prompts you to create a superuser the first time |
372 | 365 | you run it after adding ``'django.contrib.auth'`` to your |
373 | 366 | :setting:`INSTALLED_APPS`. If you need to create a superuser at a later date, |
… |
… |
How to log a user out
|
560 | 553 | Note that :func:`~django.contrib.auth.logout()` doesn't throw any errors |
561 | 554 | if the user wasn't logged in. |
562 | 555 | |
563 | | .. versionchanged:: 1.0 |
564 | | Calling ``logout()`` now cleans session data. |
565 | | |
566 | 556 | When you call :func:`~django.contrib.auth.logout()`, the session |
567 | 557 | data for the current request is completely cleaned out. All existing data |
568 | 558 | is removed. This is to prevent another person from using the same web |
-
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
index 4f32627..d77e36c 100644
a
|
b
|
production environment still will. To activate dummy caching, set
|
183 | 183 | Using a custom cache backend |
184 | 184 | ---------------------------- |
185 | 185 | |
186 | | .. versionadded:: 1.0 |
187 | | |
188 | 186 | While Django includes support for a number of cache backends out-of-the-box, |
189 | 187 | sometimes you might want to use a customized cache backend. To use an external |
190 | 188 | cache backend with Django, use a Python import path as the scheme portion (the |
… |
… |
arguments.
|
237 | 235 | The per-site cache |
238 | 236 | ================== |
239 | 237 | |
240 | | .. versionchanged:: 1.0 |
241 | | (previous versions of Django only provided a single ``CacheMiddleware`` instead |
242 | | of the two pieces described below). |
243 | | |
244 | 238 | Once the cache is set up, the simplest way to use caching is to cache your |
245 | 239 | entire site. You'll need to add |
246 | 240 | ``'django.middleware.cache.UpdateCacheMiddleware'`` and |
… |
… |
Additionally, the cache middleware automatically sets a few headers in each
|
288 | 282 | |
289 | 283 | See :ref:`topics-http-middleware` for more on middleware. |
290 | 284 | |
291 | | .. versionadded:: 1.0 |
292 | | |
293 | 285 | If a view sets its own cache expiry time (i.e. it has a ``max-age`` section in |
294 | 286 | its ``Cache-Control`` header) then the page will be cached until the expiry |
295 | 287 | time, rather than ``CACHE_MIDDLEWARE_SECONDS``. Using the decorators in |
… |
… |
minutes.
|
328 | 320 | Template fragment caching |
329 | 321 | ========================= |
330 | 322 | |
331 | | .. versionadded:: 1.0 |
332 | | |
333 | 323 | If you're after even more control, you can also cache template fragments using |
334 | 324 | the ``cache`` template tag. To give your template access to this tag, put |
335 | 325 | ``{% load cache %}`` near the top of your template. |
… |
… |
get() can take a ``default`` argument::
|
406 | 396 | >>> cache.get('my_key', 'has expired') |
407 | 397 | 'has expired' |
408 | 398 | |
409 | | .. versionadded:: 1.0 |
410 | | |
411 | 399 | To add a key only if it doesn't already exist, use the ``add()`` method. |
412 | 400 | It takes the same parameters as ``set()``, but it will not attempt to |
413 | 401 | update the cache if the key specified is already present:: |
-
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt
index a655c4e..3600425 100644
a
|
b
|
work; all are optional.
|
360 | 360 | Extra fields on many-to-many relationships |
361 | 361 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
362 | 362 | |
363 | | .. versionadded:: 1.0 |
364 | | |
365 | 363 | When you're only dealing with simple many-to-many relationships such as |
366 | 364 | mixing and matching pizzas and toppings, a standard :class:`~django.db.models.ManyToManyField` is all you need. However, sometimes |
367 | 365 | you may need to associate data with the relationship between two models. |
… |
… |
can be made; see :ref:`the model field reference <ref-onetoone>` for details.
|
525 | 523 | |
526 | 524 | .. _One-to-one relationship model example: http://www.djangoproject.com/documentation/models/one_to_one/ |
527 | 525 | |
528 | | .. versionadded:: 1.0 |
529 | | |
530 | 526 | :class:`~django.db.models.OneToOneField` fields also accept one optional argument |
531 | 527 | described in the :ref:`model field reference <ref-onetoone>`. |
532 | 528 | |
… |
… |
particular database engine.
|
578 | 574 | Custom field types |
579 | 575 | ------------------ |
580 | 576 | |
581 | | .. versionadded:: 1.0 |
582 | | |
583 | 577 | If one of the existing model fields cannot be used to fit your purposes, or if |
584 | 578 | you wish to take advantage of some less common database column types, you can |
585 | 579 | create your own field class. Full coverage of creating your own fields is |
… |
… |
query.
|
760 | 754 | Model inheritance |
761 | 755 | ================= |
762 | 756 | |
763 | | .. versionadded:: 1.0 |
764 | | |
765 | 757 | Model inheritance in Django works almost identically to the way normal |
766 | 758 | class inheritance works in Python. The only decision you have to make |
767 | 759 | is whether you want the parent models to be models in their own right |
-
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 1460fb2..98d1a36 100644
a
|
b
|
those latter objects, you could write::
|
434 | 434 | Spanning multi-valued relationships |
435 | 435 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
436 | 436 | |
437 | | .. versionadded:: 1.0 |
438 | | |
439 | 437 | When you are filtering an object based on a ``ManyToManyField`` or a reverse |
440 | 438 | ``ForeignKeyField``, there are two different sorts of filter you may be |
441 | 439 | interested in. Consider the ``Blog``/``Entry`` relationship (``Blog`` to |
… |
… |
complete query set::
|
708 | 706 | Updating multiple objects at once |
709 | 707 | ================================= |
710 | 708 | |
711 | | .. versionadded:: 1.0 |
712 | | |
713 | 709 | Sometimes you want to set a field to a particular value for all the objects in |
714 | 710 | a ``QuerySet``. You can do this with the ``update()`` method. For example:: |
715 | 711 | |
… |
… |
standpoint. For instructions, see :ref:`topics-db-sql`.
|
993 | 989 | Finally, it's important to note that the Django database layer is merely an |
994 | 990 | interface to your database. You can access your database via other tools, |
995 | 991 | programming languages or database frameworks; there's nothing Django-specific |
996 | | about your database. |
997 | | No newline at end of file |
| 992 | about your database. |
-
diff --git a/docs/topics/email.txt b/docs/topics/email.txt
index 2521385..875cc70 100644
a
|
b
|
from the request's POST data, sends that to admin@example.com and redirects to
|
181 | 181 | The EmailMessage and SMTPConnection classes |
182 | 182 | =========================================== |
183 | 183 | |
184 | | .. versionadded:: 1.0 |
185 | | |
186 | 184 | Django's ``send_mail()`` and ``send_mass_mail()`` functions are actually thin |
187 | 185 | wrappers that make use of the ``EmailMessage`` and ``SMTPConnection`` classes |
188 | 186 | in ``django.core.mail``. If you ever need to customize the way Django sends |
-
diff --git a/docs/topics/files.txt b/docs/topics/files.txt
index f4cb672..5a4d07e 100644
a
|
b
|
|
4 | 4 | Managing files |
5 | 5 | ============== |
6 | 6 | |
7 | | .. versionadded:: 1.0 |
8 | | |
9 | 7 | This document describes Django's file access APIs. |
10 | 8 | |
11 | 9 | By default, Django stores files locally, using the :setting:`MEDIA_ROOT` and |
-
diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt
index 5cc76bd..846233f 100644
a
|
b
|
There are three code paths here:
|
115 | 115 | 3. If the form has been submitted but is invalid, the bound form instance is |
116 | 116 | passed on to the template. |
117 | 117 | |
118 | | .. versionchanged:: 1.0 |
119 | | The ``cleaned_data`` attribute was called ``clean_data`` in earlier releases. |
120 | | |
121 | 118 | The distinction between **bound** and **unbound** forms is important. An unbound |
122 | 119 | form does not have any data associated with it; when rendered to the user, it |
123 | 120 | will be empty or will contain default values. A bound form does have submitted |
-
diff --git a/docs/topics/http/file-uploads.txt b/docs/topics/http/file-uploads.txt
index 24ff0eb..6875d11 100644
a
|
b
|
File Uploads
|
6 | 6 | |
7 | 7 | .. currentmodule:: django.core.files |
8 | 8 | |
9 | | .. versionadded:: 1.0 |
10 | | |
11 | 9 | Most Web sites wouldn't be complete without a way to upload files. When Django |
12 | 10 | handles a file upload, the file data ends up placed in ``request.FILES`` (for |
13 | 11 | more on the ``request`` object see the documentation for :ref:`request and |
-
diff --git a/docs/topics/http/sessions.txt b/docs/topics/http/sessions.txt
index 81d4917..9818fa5 100644
a
|
b
|
To enable session functionality, do the following:
|
25 | 25 | and run ``manage.py syncdb`` to install the single database table |
26 | 26 | that stores session data. |
27 | 27 | |
28 | | .. versionchanged:: 1.0 |
29 | | This step is optional if you're not using the database session backend; |
30 | | see `configuring the session engine`_. |
31 | | |
32 | 28 | If you don't want to use sessions, you might as well remove the |
33 | 29 | ``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES`` and ``'django.contrib.sessions'`` |
34 | 30 | from your ``INSTALLED_APPS``. It'll save you a small bit of overhead. |
… |
… |
from your ``INSTALLED_APPS``. It'll save you a small bit of overhead.
|
36 | 32 | Configuring the session engine |
37 | 33 | ============================== |
38 | 34 | |
39 | | .. versionadded:: 1.0 |
40 | | |
41 | 35 | By default, Django stores sessions in your database (using the model |
42 | 36 | ``django.contrib.sessions.models.Session``). Though this is convenient, in |
43 | 37 | some setups it's faster to store session data elsewhere, so Django can be |
… |
… |
A session object has the following standard dictionary methods:
|
109 | 103 | |
110 | 104 | * ``clear()`` |
111 | 105 | |
112 | | .. versionadded:: 1.0 |
113 | | ``setdefault()`` and ``clear()`` are new in this version. |
114 | | |
115 | 106 | It also has these methods: |
116 | 107 | |
117 | 108 | * ``flush()`` |
118 | 109 | |
119 | | .. versionadded:: 1.0 |
120 | | |
121 | 110 | Delete the current session data from the database and regenerate the |
122 | 111 | session key value that is sent back to the user in the cookie. This is |
123 | 112 | used if you want to ensure that the previous session data can't be |
… |
… |
It also has these methods:
|
144 | 133 | |
145 | 134 | * ``set_expiry(value)`` |
146 | 135 | |
147 | | .. versionadded:: 1.0 |
148 | | |
149 | 136 | Sets the expiration time for the session. You can pass a number of |
150 | 137 | different values: |
151 | 138 | |
… |
… |
It also has these methods:
|
165 | 152 | |
166 | 153 | * ``get_expiry_age()`` |
167 | 154 | |
168 | | .. versionadded:: 1.0 |
169 | | |
170 | 155 | Returns the number of seconds until this session expires. For sessions |
171 | 156 | with no custom expiration (or those set to expire at browser close), this |
172 | 157 | will equal ``settings.SESSION_COOKIE_AGE``. |
173 | 158 | |
174 | 159 | * ``get_expiry_date()`` |
175 | 160 | |
176 | | .. versionadded:: 1.0 |
177 | | |
178 | 161 | Returns the date this session will expire. For sessions with no custom |
179 | 162 | expiration (or those set to expire at browser close), this will equal the |
180 | 163 | date ``settings.SESSION_COOKIE_AGE`` seconds from now. |
181 | 164 | |
182 | 165 | * ``get_expire_at_browser_close()`` |
183 | 166 | |
184 | | .. versionadded:: 1.0 |
185 | | |
186 | 167 | Returns either ``True`` or ``False``, depending on whether the user's |
187 | 168 | session cookie will expire when the user's Web browser is closed. |
188 | 169 | |
… |
… |
Here's a typical usage example::
|
269 | 250 | Using sessions out of views |
270 | 251 | =========================== |
271 | 252 | |
272 | | .. versionadded:: 1.0 |
273 | | |
274 | 253 | An API is available to manipulate session data outside of a view:: |
275 | 254 | |
276 | 255 | >>> from django.contrib.sessions.backends.db import SessionStore |
… |
… |
browser-length cookies -- cookies that expire as soon as the user closes his or
|
351 | 330 | her browser. Use this if you want people to have to log in every time they open |
352 | 331 | a browser. |
353 | 332 | |
354 | | .. versionadded:: 1.0 |
355 | | |
356 | 333 | This setting is a global default and can be overwritten at a per-session level |
357 | 334 | by explicitly calling ``request.session.set_expiry()`` as described above in |
358 | 335 | `using sessions in views`_. |
… |
… |
A few :ref:`Django settings <ref-settings>` give you control over session behavi
|
382 | 359 | SESSION_ENGINE |
383 | 360 | -------------- |
384 | 361 | |
385 | | .. versionadded:: 1.0 |
386 | | |
387 | 362 | Default: ``django.contrib.sessions.backends.db`` |
388 | 363 | |
389 | 364 | Controls where Django stores session data. Valid values are: |
… |
… |
See `configuring the session engine`_ for more details.
|
397 | 372 | SESSION_FILE_PATH |
398 | 373 | ----------------- |
399 | 374 | |
400 | | .. versionadded:: 1.0 |
401 | | |
402 | 375 | Default: ``/tmp/`` |
403 | 376 | |
404 | 377 | If you're using file-based session storage, this sets the directory in |
-
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt
index b60ccdd..b02dcc3 100644
a
|
b
|
Optional arguments
|
43 | 43 | |
44 | 44 | ``mimetype`` |
45 | 45 | |
46 | | .. versionadded:: 1.0 |
47 | | |
48 | 46 | The MIME type to use for the resulting document. Defaults to the value of |
49 | 47 | the :setting:`DEFAULT_CONTENT_TYPE` setting. |
50 | 48 | |
-
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index db9a348..3845bd0 100644
a
|
b
|
The remaining arguments should be tuples in this format::
|
220 | 220 | url |
221 | 221 | --- |
222 | 222 | |
223 | | .. versionadded:: 1.0 |
224 | | |
225 | 223 | You can use the ``url()`` function, instead of a tuple, as an argument to |
226 | 224 | ``patterns()``. This is convenient if you want to specify a name without the |
227 | 225 | optional extra arguments dictionary. For example:: |
… |
… |
the view prefix (as explained in "The view prefix" above) will have no effect.
|
532 | 530 | Naming URL patterns |
533 | 531 | =================== |
534 | 532 | |
535 | | .. versionadded:: 1.0 |
536 | | |
537 | 533 | It's fairly common to use the same view function in multiple URL patterns in |
538 | 534 | your URLconf. For example, these two URL patterns both point to the ``archive`` |
539 | 535 | view:: |
-
diff --git a/docs/topics/i18n.txt b/docs/topics/i18n.txt
index 8ba2f9c..36d7859 100644
a
|
b
|
following this algorithm:
|
594 | 594 | |
595 | 595 | * Failing that, it looks for a cookie. |
596 | 596 | |
597 | | .. versionchanged:: 1.0 |
598 | | |
599 | 597 | In Django version 0.96 and before, the cookie's name is hard-coded to |
600 | 598 | ``django_language``. In Django 1,0, The cookie name is set by the |
601 | 599 | ``LANGUAGE_COOKIE_NAME`` setting. (The default name is |
-
diff --git a/docs/topics/pagination.txt b/docs/topics/pagination.txt
index 455f62a..e30c5b6 100644
a
|
b
|
Pagination
|
7 | 7 | .. module:: django.core.paginator |
8 | 8 | :synopsis: Classes to help you easily manage paginated data. |
9 | 9 | |
10 | | .. versionchanged:: 1.0 |
11 | | Pagination facilities have been almost fully reworked. |
12 | | |
13 | 10 | Django provides a few classes that help you manage paginated data -- that is, |
14 | 11 | data that's split across several pages, with "Previous/Next" links. These |
15 | 12 | classes live in :file:`django/core/paginator.py`. |
-
diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt
index 66361c8..e0ac9ba 100644
a
|
b
|
wouldn't know which one of the blocks' content to use.
|
397 | 397 | Automatic HTML escaping |
398 | 398 | ======================= |
399 | 399 | |
400 | | .. versionadded:: 1.0 |
401 | | |
402 | 400 | When generating HTML from templates, there's always a risk that a variable will |
403 | 401 | include characters that affect the resulting HTML. For example, consider this |
404 | 402 | template fragment:: |
… |
… |
template (e.g., one that has ``{% extends "foo.html" %}``) will *not* have
|
645 | 643 | access to the comments template tags and filters. The child template is |
646 | 644 | responsible for its own ``{% load comments %}``. |
647 | 645 | |
648 | | This is a feature for the sake of maintainability and sanity. |
649 | | No newline at end of file |
| 646 | This is a feature for the sake of maintainability and sanity. |
-
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index 0916f52..bc8f7f0 100644
a
|
b
|
with this command::
|
257 | 257 | |
258 | 258 | Note that we used ``animals``, not ``myproject.animals``. |
259 | 259 | |
260 | | .. versionadded:: 1.0 |
261 | | You can now choose which test to run. |
262 | | |
263 | 260 | If you use unit tests, as opposed to |
264 | 261 | doctests, you can be even *more* specific in choosing which tests to execute. |
265 | 262 | To run a single test case in an application (for example, the |
… |
… |
etc. The test database is created by the user specified by
|
296 | 293 | :setting:`DATABASE_USER`, so you'll need to make sure that the given user |
297 | 294 | account has sufficient privileges to create a new database on the system. |
298 | 295 | |
299 | | .. versionadded:: 1.0 |
300 | | |
301 | 296 | For fine-grained control over the |
302 | 297 | character encoding of your test database, use the |
303 | 298 | :setting:`TEST_DATABASE_CHARSET` setting. If you're using MySQL, you can also |
… |
… |
arguments at time of construction:
|
546 | 541 | |
547 | 542 | .. method:: Client.login(**credentials) |
548 | 543 | |
549 | | .. versionadded:: 1.0 |
550 | | |
551 | 544 | If your site uses Django's :ref:`authentication system<topics-auth>` |
552 | 545 | and you deal with logging in users, you can use the test client's |
553 | 546 | ``login()`` method to simulate the effect of a user logging into the |
… |
… |
arguments at time of construction:
|
586 | 579 | |
587 | 580 | .. method:: Client.logout() |
588 | 581 | |
589 | | .. versionadded:: 1.0 |
590 | | |
591 | 582 | If your site uses Django's :ref:`authentication system<topics-auth>`, |
592 | 583 | the ``logout()`` method can be used to simulate the effect of a user |
593 | 584 | logging out of your site. |
… |
… |
additions.
|
734 | 725 | Default test client |
735 | 726 | ~~~~~~~~~~~~~~~~~~~ |
736 | 727 | |
737 | | .. versionadded:: 1.0 |
738 | | |
739 | 728 | .. attribute:: TestCase.client |
740 | 729 | |
741 | 730 | Every test case in a ``django.test.TestCase`` instance has access to an |
… |
… |
or by the order of test execution.
|
835 | 824 | URLconf configuration |
836 | 825 | ~~~~~~~~~~~~~~~~~~~~~ |
837 | 826 | |
838 | | .. versionadded:: 1.0 |
839 | | |
840 | 827 | .. attribute:: TestCase.urls |
841 | 828 | |
842 | 829 | If your application provides views, you may want to include tests that use the |
… |
… |
URLconf for the duration of the test case.
|
870 | 857 | Emptying the test outbox |
871 | 858 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
872 | 859 | |
873 | | .. versionadded:: 1.0 |
874 | | |
875 | 860 | If you use Django's custom ``TestCase`` class, the test runner will clear the |
876 | 861 | contents of the test e-mail outbox at the start of each test case. |
877 | 862 | |
… |
… |
For more detail on e-mail services during tests, see `E-mail services`_.
|
880 | 865 | Assertions |
881 | 866 | ~~~~~~~~~~ |
882 | 867 | |
883 | | .. versionadded:: 1.0 |
884 | | |
885 | 868 | As Python's normal ``unittest.TestCase`` class implements assertion methods |
886 | 869 | such as ``assertTrue`` and ``assertEquals``, Django's custom ``TestCase`` class |
887 | 870 | provides a number of custom assertion methods that are useful for testing Web |
… |
… |
applications:
|
934 | 917 | E-mail services |
935 | 918 | --------------- |
936 | 919 | |
937 | | .. versionadded:: 1.0 |
938 | | |
939 | 920 | If any of your Django views send e-mail using :ref:`Django's e-mail |
940 | 921 | functionality <topics-email>`, you probably don't want to send e-mail each time |
941 | 922 | you run a test using that view. For this reason, Django's test runner |
… |
… |
that can be executed from Python code.
|
1026 | 1007 | Defining a test runner |
1027 | 1008 | ---------------------- |
1028 | 1009 | |
1029 | | .. versionadded:: 1.0 |
1030 | | |
1031 | 1010 | .. currentmodule:: django.test.simple |
1032 | 1011 | |
1033 | 1012 | By convention, a test runner should be called ``run_tests``. The only strict |
… |
… |
provides some utilities that can be useful during testing.
|
1106 | 1085 | ``create_test_db()`` has the side effect of modifying |
1107 | 1086 | ``settings.DATABASE_NAME`` to match the name of the test database. |
1108 | 1087 | |
1109 | | .. versionchanged:: 1.0 |
1110 | | ``create_test_db()`` now returns the name of the test database. |
1111 | | |
1112 | 1088 | .. function:: destroy_test_db(old_database_name, verbosity=1) |
1113 | 1089 | |
1114 | 1090 | Destroys the database whose name is in the :setting:`DATABASE_NAME` setting |