Skip to content

Commit

Permalink
Clarified default name of M2M relationship DB table.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiro committed Jul 25, 2012
1 parent f758bda commit 5083743
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions docs/ref/models/fields.txt
Expand Up @@ -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:

Expand Down Expand Up @@ -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:

Expand Down
3 changes: 2 additions & 1 deletion docs/topics/db/models.txt
Expand Up @@ -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
Expand Down

0 comments on commit 5083743

Please sign in to comment.