浏览代码

Fixed #29756 -- Doc'd that model field names can't end with an underscore.

Tim Graham 6 年之前
父节点
当前提交
d483a5f0dc
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      docs/topics/db/models.txt

+ 3 - 1
docs/topics/db/models.txt

@@ -649,7 +649,7 @@ just refer to the other model class wherever needed. For example::
 Field name restrictions
 Field name restrictions
 -----------------------
 -----------------------
 
 
-Django places only two restrictions on model field names:
+Django places some restrictions on model field names:
 
 
 1. A field name cannot be a Python reserved word, because that would result
 1. A field name cannot be a Python reserved word, because that would result
    in a Python syntax error. For example::
    in a Python syntax error. For example::
@@ -663,6 +663,8 @@ Django places only two restrictions on model field names:
        class Example(models.Model):
        class Example(models.Model):
            foo__bar = models.IntegerField() # 'foo__bar' has two underscores!
            foo__bar = models.IntegerField() # 'foo__bar' has two underscores!
 
 
+3. A field name cannot end with an underscore, for similar reasons.
+
 These limitations can be worked around, though, because your field name doesn't
 These limitations can be worked around, though, because your field name doesn't
 necessarily have to match your database column name. See the
 necessarily have to match your database column name. See the
 :attr:`~Field.db_column` option.
 :attr:`~Field.db_column` option.