本文整理匯總了Python中django.forms.ClearableFileInput.is_required方法的典型用法代碼示例。如果您正苦於以下問題:Python ClearableFileInput.is_required方法的具體用法?Python ClearableFileInput.is_required怎麽用?Python ClearableFileInput.is_required使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms.ClearableFileInput
的用法示例。
在下文中一共展示了ClearableFileInput.is_required方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_clear_input_checked_returns_false_only_if_not_required
# 需要導入模塊: from django.forms import ClearableFileInput [as 別名]
# 或者: from django.forms.ClearableFileInput import is_required [as 別名]
def test_clear_input_checked_returns_false_only_if_not_required(self):
"""
ClearableFileInput.value_from_datadict never returns False if the field
is required.
"""
widget = ClearableFileInput()
widget.is_required = True
field = SimpleUploadedFile("something.txt", b"content")
value = widget.value_from_datadict(data={"myfile-clear": True}, files={"myfile": field}, name="myfile")
self.assertEqual(value, field)
示例2: test_clear_input_renders_only_if_not_required
# 需要導入模塊: from django.forms import ClearableFileInput [as 別名]
# 或者: from django.forms.ClearableFileInput import is_required [as 別名]
def test_clear_input_renders_only_if_not_required(self):
"""
A ClearableFileInput with is_required=False does not render a clear
checkbox.
"""
widget = ClearableFileInput()
widget.is_required = True
self.check_html(widget, 'myfile', FakeFieldFile(), html=(
"""
Currently: <a href="something">something</a> <br>
Change: <input type="file" name="myfile">
"""
))