Fixed #11864 -- Improved the "see also" section of the many-to-one model topic guide to more clearly connect people to the backwards-related objects docs and to the correct point in the model tests for sample code (since the doctests went away). Thanks to dwillis for the work on the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15758 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gabriel Hurley 2011-03-04 22:29:16 +00:00
parent 32255c20a5
commit 8940969a7a
1 changed files with 14 additions and 10 deletions

View File

@ -284,7 +284,7 @@ relationships: many-to-one, many-to-many and one-to-one.
Many-to-one relationships
~~~~~~~~~~~~~~~~~~~~~~~~~
To define a many-to-one relationship, use :class:`~django.db.models.ForeignKey`.
To define a many-to-one relationship, use :class:`django.db.models.ForeignKey`.
You use it just like any other :class:`~django.db.models.Field` type: by
including it as a class attribute of your model.
@ -318,14 +318,18 @@ whatever you want. For example::
.. seealso::
See the `Many-to-one relationship model example`_ for a full example.
:class:`~django.db.models.ForeignKey` fields accept a number of extra
arguments which are explained in :ref:`the model field reference
<foreign-key-arguments>`. These options help define how the relationship
should work; all are optional.
.. _Many-to-one relationship model example: http://code.djangoproject.com/browser/django/trunk/tests/modeltests/many_to_one/models.py
For details on accessing backwards-related objects, see the
`Following relationships backward example`_.
:class:`~django.db.models.ForeignKey` fields also accept a number of extra
arguments which are explained in :ref:`the model field reference
<foreign-key-arguments>`. These options help define how the relationship should
work; all are optional.
For sample code, see the `Many-to-one relationship model tests`_.
.. _Following relationships backward example: http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects
.. _Many-to-one relationship model tests: http://code.djangoproject.com/browser/django/trunk/tests/modeltests/many_to_one
Many-to-many relationships
~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -929,7 +933,7 @@ The second type of model inheritance supported by Django is when each model in
the hierarchy is a model all by itself. Each model corresponds to its own
database table and can be queried and created individually. The inheritance
relationship introduces links between the child model and each of its parents
(via an automatically-created :class:`~django.db.models.fields.OneToOneField`).
(via an automatically-created :class:`~django.db.models.OneToOneField`).
For example::
class Place(models.Model):
@ -1208,7 +1212,7 @@ Field name "hiding" is not permitted
In normal Python class inheritance, it is permissible for a child class to
override any attribute from the parent class. In Django, this is not permitted
for attributes that are :class:`~django.db.models.fields.Field` instances (at
for attributes that are :class:`~django.db.models.Field` instances (at
least, not at the moment). If a base class has a field called ``author``, you
cannot create another model field called ``author`` in any class that inherits
from that base class.
@ -1221,7 +1225,7 @@ difference between Django model inheritance and Python class inheritance isn't
arbitrary.
This restriction only applies to attributes which are
:class:`~django.db.models.fields.Field` instances. Normal Python attributes
:class:`~django.db.models.Field` instances. Normal Python attributes
can be overridden if you wish. It also only applies to the name of the
attribute as Python sees it: if you are manually specifying the database
column name, you can have the same column name appearing in both a child and