Django Book 翻译
菜单>:
TOC
返回
原文:
.. table:: Table B-6. ManyToManyField Options +--------------------+-------------------------------------------------------------------------------------+ |Argument |Description | +====================+=====================================================================================+ |``related_name`` |The name to use for the relation from the related object back to this one. See | | |Appendix C for more information. | +--------------------+-------------------------------------------------------------------------------------+ |``filter_interface``|Use a nifty, unobtrusive JavaScript filter interface instead of the | | |usability-challenged ``
`` in the admin form for this object. The | | |value should be ``models.HORIZONTAL`` or ``models.VERTICAL`` (i.e., should the | | |interface be stacked horizontally or vertically). | +--------------------+-------------------------------------------------------------------------------------+ |``limit_choices_to``|See the description under ``ForeignKey`` . | +--------------------+-------------------------------------------------------------------------------------+ |``symmetrical`` |Only used in the definition of ``ManyToManyField`` on self. Consider the following | | |model: | | | | | |:: | | | | | | | | | class Person(models.Model): | | | friends = models.ManyToManyField("self") | | | | | |.. | | | | | | | | | | | |When Django processes this model, it identifies that it has a ``ManyToManyField`` on | | |itself, and as a result, it doesnt add a ``person_set`` attribute to the ``Person`` | | |class. Instead, the ``ManyToManyField`` is assumed to be symmetrical that is, if I am| | |your friend, then you are my friend. | | | | | |If you do not want symmetry in ``ManyToMany`` relationships with ``self`` , set | | |``symmetrical`` to ``False`` . This will force Django to add the descriptor for the | | |reverse relationship, allowing ``ManyToMany`` relationships to be nonsymmetrical. | +--------------------+-------------------------------------------------------------------------------------+ |``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. | +--------------------+-------------------------------------------------------------------------------------+
翻译:
.. table:: 表B-6. ManyToManyField选项 +--------------------+-------------------------------------------------------------------------------------+ |参数 |描述 | +====================+=====================================================================================+ |``related_name`` |关联对象反向引用描述符。更多信息参见附录C。 | +--------------------+-------------------------------------------------------------------------------------+ |``filter_interface``|在这个对象的管理界面里面,使用简单易用的JavaScript过滤界面,而不是使用可用性较差的 | | |``
`` 。它的值应该是 ``models.HORIZONTAL`` 或者 ``models.VERTICAL`` | | |(就是说界面应该横放还是竖放)。 | +--------------------+-------------------------------------------------------------------------------------+ |``limit_choices_to``|参见 ``ForeignKey`` 中对本项的描述。 | +--------------------+-------------------------------------------------------------------------------------+ |``symmetrical`` |仅用于模型定义指向自身的 ``ManyToManyField`` 的情况。看下面这个模型: | | | | | |:: | | | | | | | | | class Person(models.Model): | | | friends = models.ManyToManyField("self") | | | | | |.. | | | | | | | | | | | |当Django处理这个模型时,会发现它有一个指向自身的 ``ManyToManyField`` ,它因此就不会在| | |``Person`` 类中添加 ``person_set`` 属性。而对于 ``ManyToManyField`` ,我们会假定这种 | | |关系是对称的,就是说,如果我是你的朋友,你也是我的朋友。 | | | | | |在对 ``self`` 的 ``ManyToMany`` 关系中,如果你不需要这种对称性,你可以把 | | |``symmetrical`` 的值设为 ``False`` 。这样就会强制Django给关系的另外一方添加描述符, | | |从而使这种关系不是对称的。 | +--------------------+-------------------------------------------------------------------------------------+ |``db_table`` |用来保存多对多数据的表的名字。如果没有提供本项的话,Django会把两个表的名字连接起来当 | | |做多对多数据表的默认名字。 | +--------------------+-------------------------------------------------------------------------------------+
备注:
译者: