本文整理匯總了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']))