Python django.forms.widgets.FileInput() Examples

The following are 1 code examples of django.forms.widgets.FileInput(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.forms.widgets , or try the search function .
Example #1
Source File: test_cluster_form.py    From django-modelcluster with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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']))