diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-07-09 17:11:34 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-07-09 17:11:34 +0000 |
| commit | ef1a9eeb64b24a49769b107a9361643bd7e7a688 (patch) | |
| tree | 35e92a9d96da0e8141ef9bcc18a2b826ca66aae3 /docs | |
| parent | 60947322a582e4bc3f07622024ef7e2d470b0d68 (diff) | |
[multi-db] Merge trunk to [3302]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/db-api.txt | 37 | ||||
| -rw-r--r-- | docs/django-admin.txt | 5 | ||||
| -rw-r--r-- | docs/forms.txt | 2 | ||||
| -rw-r--r-- | docs/outputting_pdf.txt | 2 | ||||
| -rw-r--r-- | docs/sessions.txt | 20 | ||||
| -rw-r--r-- | docs/settings.txt | 6 | ||||
| -rw-r--r-- | docs/templates.txt | 16 |
7 files changed, 64 insertions, 24 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index 15b70ee028..ce6bb0ab3b 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -1121,35 +1121,37 @@ Note this is only available in MySQL and requires direct manipulation of the database to add the full-text index. Default lookups are exact -~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------- If you don't provide a lookup type -- that is, if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be ``exact``. For example, the following two statements are equivalent:: - Blog.objects.get(id=14) - Blog.objects.get(id__exact=14) + Blog.objects.get(id__exact=14) # Explicit form + Blog.objects.get(id=14) # __exact is implied This is for convenience, because ``exact`` lookups are the common case. The pk lookup shortcut -~~~~~~~~~~~~~~~~~~~~~~ +---------------------- For convenience, Django provides a ``pk`` lookup type, which stands for "primary_key". This is shorthand for "an exact lookup on the primary-key." In the example ``Blog`` model, the primary key is the ``id`` field, so these -two statements are equivalent:: +three statements are equivalent:: - Blog.objects.get(id__exact=14) - Blog.objects.get(pk=14) + Blog.objects.get(id__exact=14) # Explicit form + Blog.objects.get(id=14) # __exact is implied + Blog.objects.get(pk=14) # pk implies id__exact -``pk`` lookups also work across joins. For example, these two statements are +``pk`` lookups also work across joins. For example, these three statements are equivalent:: - Entry.objects.filter(blog__id__exact=3) - Entry.objects.filter(blog__pk=3) + Entry.objects.filter(blog__id__exact=3) # Explicit form + Entry.objects.filter(blog__id=3) # __exact is implied + Entry.objects.filter(blog__pk=3) # __pk implies __id__exact Lookups that span relationships ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1550,6 +1552,21 @@ loaded, Django iterates over every model in ``INSTALLED_APPS`` and creates the backward relationships in memory as needed. Essentially, one of the functions of ``INSTALLED_APPS`` is to tell Django the entire model domain. +Queries over related objects +---------------------------- + +Queries involving related objects follow the same rules as queries involving +normal value fields. When specifying the the value for a query to match, you +may use either an object instance itself, or the primary key value for the +object. + +For example, if you have a Blog object ``b`` with ``id=5``, the following +three queries would be identical:: + + Entry.objects.filter(blog=b) # Query using object instance + Entry.objects.filter(blog=b.id) # Query using id from instance + Entry.objects.filter(blog=5) # Query using id directly + Deleting objects ================ diff --git a/docs/django-admin.txt b/docs/django-admin.txt index 3334ae4530..04d86aa3b4 100644 --- a/docs/django-admin.txt +++ b/docs/django-admin.txt @@ -126,8 +126,9 @@ you run it, you'll want to look over the generated models yourself to make customizations. In particular, you'll need to rearrange models' order, so that models that refer to other models are ordered properly. -Primary keys are automatically introspected for PostgreSQL and MySQL, in which -case Django puts in the ``primary_key=True`` where needed. +Primary keys are automatically introspected for PostgreSQL, MySQL and +SQLite, in which case Django puts in the ``primary_key=True`` where +needed. ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection only works in PostgreSQL and with certain types of MySQL tables. diff --git a/docs/forms.txt b/docs/forms.txt index 5026bc1bab..2fbe373744 100644 --- a/docs/forms.txt +++ b/docs/forms.txt @@ -50,7 +50,7 @@ model that "knows" how to create or modify instances of that model and how to validate data for the object. Manipulators come in two flavors: ``AddManipulators`` and ``ChangeManipulators``. Functionally they are quite similar, but the former knows how to create new instances of the model, while -the later modifies existing instances. Both types of classes are automatically +the latter modifies existing instances. Both types of classes are automatically created when you define a new class:: >>> from mysite.myapp.models import Place diff --git a/docs/outputting_pdf.txt b/docs/outputting_pdf.txt index a58cf2c217..edd34aca24 100644 --- a/docs/outputting_pdf.txt +++ b/docs/outputting_pdf.txt @@ -110,7 +110,7 @@ efficient. Here's the above "Hello World" example rewritten to use from cStringIO import StringIO from reportlab.pdfgen import canvas - from django.utils.httpwrappers import HttpResponse + from django.http import HttpResponse def some_view(request): # Create the HttpResponse object with the appropriate PDF headers. diff --git a/docs/sessions.txt b/docs/sessions.txt index 2dba491159..c473d0a3db 100644 --- a/docs/sessions.txt +++ b/docs/sessions.txt @@ -10,18 +10,22 @@ Cookies contain a session ID -- not the data itself. Enabling sessions ================= -Sessions are implemented via middleware_. +Sessions are implemented via a piece of middleware_ and a Django model. -Turn session functionality on and off by editing the ``MIDDLEWARE_CLASSES`` -setting. To activate sessions, make sure ``MIDDLEWARE_CLASSES`` contains -``'django.contrib.sessions.middleware.SessionMiddleware'``. +To enable session functionality, do these two things: -The default ``settings.py`` created by ``django-admin.py startproject`` has -``SessionMiddleware`` activated. + * Edit the ``MIDDLEWARE_CLASSES`` setting and make sure + ``MIDDLEWARE_CLASSES`` contains ``'django.contrib.sessions.middleware.SessionMiddleware'``. + The default ``settings.py`` created by ``django-admin.py startproject`` has + ``SessionMiddleware`` activated. + + * Add ``'django.contrib.sessions'`` to your ``INSTALLED_APPS`` setting, and + run ``manage.py syncdb`` to install the single database table that stores + session data. If you don't want to use sessions, you might as well remove the -``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES``. It'll save you a small -bit of overhead. +``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES`` and ``'django.contrib.sessions'`` +from your ``INSTALLED_APPS``. It'll save you a small bit of overhead. .. _middleware: http://www.djangoproject.com/documentation/middleware/ diff --git a/docs/settings.txt b/docs/settings.txt index 4f4fb70298..9e1c6b529b 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -729,6 +729,10 @@ TIME_ZONE Default: ``'America/Chicago'`` A string representing the time zone for this installation. `See available choices`_. +(Note that list of available choices lists more than one on the same line; +you'll want to use just one of the choices for a given time zone. For instance, +one line says ``'Europe/London GB GB-Eire'``, but you should use the first bit +of that -- ``'Europe/London'`` -- as your ``TIME_ZONE`` setting.) Note that this is the time zone to which Django will convert all dates/times -- not necessarily the timezone of the server. For example, one server may serve @@ -750,7 +754,7 @@ Default: ``True`` A boolean that specifies whether Django's internationalization system should be enabled. This provides an easy way to turn it off, for performance. If this is -set to ``False, Django will make some optimizations so as not to load the +set to ``False``, Django will make some optimizations so as not to load the internationalization machinery. YEAR_MONTH_FORMAT diff --git a/docs/templates.txt b/docs/templates.txt index 42947510d1..4ba52b3263 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -951,12 +951,26 @@ any string. pluralize ~~~~~~~~~ -Returns ``'s'`` if the value is not 1. +Returns a plural suffix if the value is not 1. By default, this suffix is ``'s'``. Example:: You have {{ num_messages }} message{{ num_messages|pluralize }}. +For words that require a suffix other than ``'s'``, you can provide an alternate +suffix as a parameter to the filter. + +Example:: + + You have {{ num_walruses }} walrus{{ num_walrus|pluralize:"es" }}. + +For words that don't pluralize by simple suffix, you can specify both a +singular and plural suffix, separated by a comma. + +Example:: + + You have {{ num_cherries }} cherr{{ num_cherries|pluralize:"y,ies" }}. + pprint ~~~~~~ |
