Fixed a couple typos in the modeltests' descriptions and made use of ReST inline literal markup for code snippets.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8325 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gary Wilson Jr 2008-08-12 14:15:38 +00:00
parent c4d07d4d50
commit 1697f4e49f
19 changed files with 65 additions and 60 deletions

View File

@ -11,7 +11,7 @@ query the database.
If you need to use a table name for a many-to-many relationship that differs
from the default generated name, use the ``db_table`` parameter on the
ManyToMany field. This has no effect on the API for querying the database.
``ManyToMany`` field. This has no effect on the API for querying the database.
"""

View File

@ -1,8 +1,8 @@
"""
42. Storing files according to a custom storage system
FileField and its variations can take a "storage" argument to specify how and
where files should be stored.
``FileField`` and its variations can take a ``storage`` argument to specify how
and where files should be stored.
"""
import tempfile

View File

@ -5,7 +5,7 @@ Fixtures are a way of loading data into the database in bulk. Fixure data
can be stored in any serializable format (including JSON and XML). Fixtures
are identified by name, and are stored in either a directory named 'fixtures'
in the application directory, on in one of the directories named in the
FIXTURE_DIRS setting.
``FIXTURE_DIRS`` setting.
"""
from django.db import models

View File

@ -2,8 +2,8 @@
34. Generic relations
Generic relations let an object have a foreign key to any object through a
content-type/object-id field. A generic foreign key can point to any object,
be it animal, vegetable, or mineral.
content-type/object-id field. A ``GenericForeignKey`` field can point to any
object, be it animal, vegetable, or mineral.
The canonical example is tags (although this example implementation is *far*
from complete).

View File

@ -2,10 +2,10 @@
8. get_latest_by
Models can have a ``get_latest_by`` attribute, which should be set to the name
of a DateField or DateTimeField. If ``get_latest_by`` exists, the model's
manager will get a ``latest()`` method, which will return the latest object in
the database according to that field. "Latest" means "having the date farthest
into the future."
of a ``DateField`` or ``DateTimeField``. If ``get_latest_by`` exists, the
model's manager will get a ``latest()`` method, which will return the latest
object in the database according to that field. "Latest" means "having the date
farthest into the future."
"""
from django.db import models

View File

@ -1,13 +1,13 @@
"""
35. DB-API Shortcuts
get_object_or_404 is a shortcut function to be used in view functions for
performing a get() lookup and raising a Http404 exception if a DoesNotExist
exception was raised during the get() call.
``get_object_or_404()`` is a shortcut function to be used in view functions for
performing a ``get()`` lookup and raising a ``Http404`` exception if a
``DoesNotExist`` exception was raised during the ``get()`` call.
get_list_or_404 is a shortcut function to be used in view functions for
performing a filter() lookup and raising a Http404 exception if a DoesNotExist
exception was raised during the filter() call.
``get_list_or_404()`` is a shortcut function to be used in view functions for
performing a ``filter()`` lookup and raising a ``Http404`` exception if a
``DoesNotExist`` exception was raised during the ``filter()`` call.
"""
from django.db import models

View File

@ -1,8 +1,9 @@
"""
33. get_or_create()
get_or_create() does what it says: it tries to look up an object with the given
parameters. If an object isn't found, it creates one with the given parameters.
``get_or_create()`` does what it says: it tries to look up an object with the
given parameters. If an object isn't found, it creates one with the given
parameters.
"""
from django.db import models

View File

@ -4,10 +4,10 @@
For many-to-many relationships that need extra fields on the intermediary
table, use an intermediary model.
In this example, an ``Article`` can have multiple ``Reporter``s, and each
``Article``-``Reporter`` combination (a ``Writer``) has a ``position`` field,
which specifies the ``Reporter``'s position for the given article (e.g. "Staff
writer").
In this example, an ``Article`` can have multiple ``Reporter`` objects, and
each ``Article``-``Reporter`` combination (a ``Writer``) has a ``position``
field, which specifies the ``Reporter``'s position for the given article
(e.g. "Staff writer").
"""
from django.db import models

View File

@ -1,8 +1,8 @@
"""
20. Multiple many-to-many relationships between the same two tables
In this example, an Article can have many Categories (as "primary") and many
Categories (as "secondary").
In this example, an ``Article`` can have many "primary" ``Category`` objects
and many "secondary" ``Category`` objects.
Set ``related_name`` to designate what the reverse relationship is called.
"""

View File

@ -1,15 +1,19 @@
"""
28. Many-to-many relationships between the same two tables
In this example, A Person can have many friends, who are also people. Friendship is a
symmetrical relationship - if I am your friend, you are my friend.
In this example, a ``Person`` can have many friends, who are also ``Person``
objects. Friendship is a symmetrical relationship - if I am your friend, you
are my friend. Here, ``friends`` is an example of a symmetrical
``ManyToManyField``.
A person can also have many idols - but while I may idolize you, you may not think
the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive
m2m fields may be non-symmetrical, and they are symmetrical by default.
A ``Person`` can also have many idols - but while I may idolize you, you may
not think the same of me. Here, ``idols`` is an example of a non-symmetrical
``ManyToManyField``. Only recursive ``ManyToManyField`` fields may be
non-symmetrical, and they are symmetrical by default.
This test validates that the m2m table will create a mangled name for the m2m table if
there will be a clash, and tests that symmetry is preserved where appropriate.
This test validates that the many-to-many table is created using a mangled name
if there is a name clash, and tests that symmetry is preserved where
appropriate.
"""
from django.db import models

View File

@ -2,7 +2,7 @@
"""
27. Default manipulators
Each model gets an AddManipulator and ChangeManipulator by default.
Each model gets an ``AddManipulator`` and ``ChangeManipulator`` by default.
"""
from django.db import models

View File

@ -1,10 +1,10 @@
"""
5. Many-to-many relationships
To define a many-to-many relationship, use ManyToManyField().
To define a many-to-many relationship, use ``ManyToManyField()``.
In this example, an article can be published in multiple publications,
and a publication has multiple articles.
In this example, an ``Article`` can be published in multiple ``Publication``
objects, and a ``Publication`` has multiple ``Article`` objects.
"""
from django.db import models

View File

@ -1,10 +1,10 @@
"""
XX. Generating HTML forms from models
This is mostly just a reworking of the form_for_model/form_for_instance tests
to use ModelForm. As such, the text may not make sense in all cases, and the
examples are probably a poor fit for the ModelForm syntax. In other words,
most of these tests should be rewritten.
This is mostly just a reworking of the ``form_for_model``/``form_for_instance``
tests to use ``ModelForm``. As such, the text may not make sense in all cases,
and the examples are probably a poor fit for the ``ModelForm`` syntax. In other
words, most of these tests should be rewritten.
"""
import os

View File

@ -1,12 +1,12 @@
"""
19. OR lookups
To perform an OR lookup, or a lookup that combines ANDs and ORs,
combine QuerySet objects using & and | operators.
To perform an OR lookup, or a lookup that combines ANDs and ORs, combine
``QuerySet`` objects using ``&`` and ``|`` operators.
Alternatively, use positional arguments, and pass one or more expressions of
clauses using the variable ``django.db.models.Q`` (or any object with an
add_to_query method).
``add_to_query`` method).
"""
# Python 2.3 doesn't have sorted()
try:

View File

@ -3,7 +3,7 @@
Specify default ordering for a model using the ``ordering`` attribute, which
should be a list or tuple of field names. This tells Django how to order
queryset results.
``QuerySet`` results.
If a field name in ``ordering`` starts with a hyphen, that field will be
ordered in descending order. Otherwise, it'll be ordered in ascending order.

View File

@ -2,8 +2,8 @@
"""
42. Serialization
``django.core.serializers`` provides interfaces to converting Django querysets
to and from "flat" data (i.e. strings).
``django.core.serializers`` provides interfaces to converting Django
``QuerySet`` objects to and from "flat" data (i.e. strings).
"""
from django.db import models

View File

@ -11,8 +11,8 @@ The server Response objects are annotated with the details
of the contexts and templates that were rendered during the
process of serving the request.
Client objects are stateful - they will retain cookie (and
thus session) details for the lifetime of the Client instance.
``Client`` objects are stateful - they will retain cookie (and
thus session) details for the lifetime of the ``Client`` instance.
This is not intended as a replacement for Twill, Selenium, or
other browser automation frameworks - it is here to allow

View File

@ -1,16 +1,16 @@
"""
38. User-registered management commands
The manage.py utility provides a number of useful commands for managing a
The ``manage.py`` utility provides a number of useful commands for managing a
Django project. If you want to add a utility command of your own, you can.
The user-defined command 'dance' is defined in the management/commands
The user-defined command ``dance`` is defined in the management/commands
subdirectory of this test application. It is a simple command that responds
with a printed message when invoked.
For more details on how to define your own manage.py commands, look at the
django.core.management.commands directory. This directory contains the
definitions for the base Django manage.py commands.
For more details on how to define your own ``manage.py`` commands, look at the
``django.core.management.commands`` directory. This directory contains the
definitions for the base Django ``manage.py`` commands.
"""
__test__ = {'API_TESTS': """