Python django.forms.widgets 模块,Widget() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.forms.widgets.Widget()

项目:django-vueformgenerator    作者:player1537    | 项目源码 | 文件源码
def test_correct_error_thrown(self):
        from django.forms.widgets import Widget
        class NotARealWidget(Widget):
            def __repr__(self):
                return "NotARealWidget"

        class TestForm(forms.Form):
            not_a_real = forms.CharField(widget=NotARealWidget)

        expected = 'Could not find component "NotARealWidget"'
        with self.assertRaises(KeyError, msg=expected) as context:
            schema = Schema().render(TestForm(data={}))