浏览代码

Fixed #30395 -- Doc'd a limitation of ModelForm.Meta.widgets.

Tobias Kunze 5 年之前
父节点
当前提交
a309821c97
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      docs/topics/forms/modelforms.txt

+ 3 - 1
docs/topics/forms/modelforms.txt

@@ -522,7 +522,9 @@ For example, if you want the ``CharField`` for the ``name`` attribute of
             }
 
 The ``widgets`` dictionary accepts either widget instances (e.g.,
-``Textarea(...)``) or classes (e.g., ``Textarea``).
+``Textarea(...)``) or classes (e.g., ``Textarea``). Note that the ``widgets``
+dictionary is ignored for a model field with a non-empty ``choices`` attribute.
+In this case, you must override the form field to use a different widget.
 
 Similarly, you can specify the ``labels``, ``help_texts`` and ``error_messages``
 attributes of the inner ``Meta`` class if you want to further customize a field.