Clarified default name of M2M relationship DB table.

This commit is contained in:
Ramiro Morales 2012-07-24 22:44:28 -03:00
parent f758bdab5e
commit 50837434db
2 changed files with 13 additions and 12 deletions

View File

@ -1074,15 +1074,14 @@ the model is related. This works exactly the same as it does for
Database Representation
~~~~~~~~~~~~~~~~~~~~~~~
Behind the scenes, Django creates an intermediary join table to
represent the many-to-many relationship. By default, this table name
is generated using the name of the many-to-many field and the model
that contains it. Since some databases don't support table names above
a certain length, these table names will be automatically truncated to
64 characters and a uniqueness hash will be used. This means you might
see table names like ``author_books_9cdf4``; this is perfectly normal.
You can manually provide the name of the join table using the
:attr:`~ManyToManyField.db_table` option.
Behind the scenes, Django creates an intermediary join table to represent the
many-to-many relationship. By default, this table name is generated using the
name of the many-to-many field and the name of the table for the model that
contains it. Since some databases don't support table names above a certain
length, these table names will be automatically truncated to 64 characters and a
uniqueness hash will be used. This means you might see table names like
``author_books_9cdf4``; this is perfectly normal. You can manually provide the
name of the join table using the :attr:`~ManyToManyField.db_table` option.
.. _manytomany-arguments:
@ -1138,8 +1137,9 @@ that control how the relationship functions.
.. attribute:: ManyToManyField.db_table
The name of the table to create for storing the many-to-many data. If this
is not provided, Django will assume a default name based upon the names of
the two tables being joined.
is not provided, Django will assume a default name based upon the names of:
the table for the model defining the relationship and the name of the field
itself.
.. _ref-onetoone:

View File

@ -384,7 +384,8 @@ Extra fields on many-to-many relationships
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When you're only dealing with simple many-to-many relationships such as
mixing and matching pizzas and toppings, a standard :class:`~django.db.models.ManyToManyField` is all you need. However, sometimes
mixing and matching pizzas and toppings, a standard
:class:`~django.db.models.ManyToManyField` is all you need. However, sometimes
you may need to associate data with the relationship between two models.
For example, consider the case of an application tracking the musical groups