Django Book 翻译
菜单>:
TOC
返回
原文:
* The ``model.objects.all()`` line is an example of *duck typing* : If it walks like a duck and talks like a duck, we can treat it like a duck. Note the code doesnt know what type of object ``model`` is; the only requirement is that ``model`` have an ``objects`` attribute, which in turn has an ``all()`` method.
翻译:
* 这一行: ``model.objects.all()`` 是 *鸭子界定* (原文:duck typing,是计算机科学中一种动态类型判断的概念)的一个例子:如果一只鸟走起来像鸭子,叫起来像鸭子,那我们就可以把它当作是鸭子了。需要注意的是代码并不知道 ``model`` 对象的类型是什么;它只要求 ``model`` 有一个 ``objects`` 属性,而这个属性有一个 ``all()`` 方法。
备注:
译者: