Django Book 翻译
菜单>:
TOC
返回
原文:
How did ``CurrentSiteManager`` know which field of ``Photo`` was the ``Site`` ? It defaults to looking for a field called ``site`` . If your model has a ``ForeignKey`` or ``ManyToManyField`` called something *other* than ``site`` , you need to explicitly pass that as the parameter to ``CurrentSiteManager`` . The following model, which has a field called ``publish_on`` , demonstrates this:
翻译:
``CurrentSiteManager`` 是如何知道 ``Photo`` 的哪个字段是 ``Site`` 呢?缺省情况下,它会查找一个叫做 ``site`` 的字段。如果模型中有个 ``外键`` 或 ``多对多字段`` 叫做 ``site`` *之外* 的名字,你必须显示地将它作为参数传递给 ``CurrentSiteManager`` 。下面的模型中有个叫做 ``publish_on`` 的字段,如下所示:
备注:
译者: