Django Book 翻译
菜单>:
TOC
返回
原文:
Avoid using ``null`` on string-based fields such as ``CharField`` and ``TextField`` unless you have an excellent reason. If a string-based field has ``null=True`` , that means it has two possible values for no data: ``NULL`` and the empty string. In most cases, its redundant to have two possible values for no data; Djangos convention is to use the empty string, not ``NULL`` .
翻译:
如果没有充分理由的话,应该尽量避免对诸如 ``CharField`` 和 ``TextField`` 这样字符串字段使用 ``null`` 参数。如果对字符串字段指定了 ``null=True`` 的话,这意味着空数据有两种可能的值: ``NULL`` 和空字符串。而大多数情况下,空数据没必要对应两种可能的值,所以Django中习惯使用空字符串,而不是 ``NULL`` 。
备注:
译者: