本文整理汇总了Python中django.forms.widgets.FileInput方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.FileInput方法的具体用法?Python widgets.FileInput怎么用?Python widgets.FileInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.widgets
的用法示例。
在下文中一共展示了widgets.FileInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_widgets_with_media_on_child_form
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import FileInput [as 别名]
def test_widgets_with_media_on_child_form(self):
"""
The media property of ClusterForm should pick up media defined on child forms too
"""
class FancyTextInput(TextInput):
class Media:
js = ['fancy-text-input.js']
class FancyFileUploader(FileInput):
class Media:
js = ['fancy-file-uploader.js']
class FormWithWidgetMedia(ClusterForm):
class Meta:
model = Gallery
fields = ['title']
widgets = {
'title': FancyTextInput,
}
formsets = {
'images': {
'fields': ['image'],
'widgets': {'image': FancyFileUploader}
}
}
form = FormWithWidgetMedia()
self.assertIn('fancy-text-input.js', str(form.media['js']))
self.assertIn('fancy-file-uploader.js', str(form.media['js']))