class Meta: """ Form meta attributes """ model = Section widgets = { "title": TextEditorWidget(configuration=CKEDITOR_CONFIGURATION_NAME), "attributes": AttributesWidget(), } fields = { "title", "template", "attributes", }
def __init__(self, *args, **kwargs): super(CarouselSlidePluginForm, self).__init__(*args, **kwargs) self.fields['link_attributes'].widget = AttributesWidget(val_attrs={'style': 'width:500px!important'})
def __init__(self, *args, **kwargs): super(FilerFileForm, self).__init__(*args, **kwargs) self.fields['link_attributes'].widget = AttributesWidget()
def __init__(self, *args, **kwargs): super(LinkForm, self).__init__(*args, **kwargs) self.fields['attributes'].widget = AttributesWidget()
def __init__(self, *args, **kwargs): super(TestPluginForm, self).__init__(*args, **kwargs) self.fields['attributes2'].widget = AttributesWidget( key_attrs={'style': 'width:250px'}, val_attrs={'style': 'width:500px'}, )
def __init__(self, *args, **kwargs): super(CarouselSlidePluginForm, self).__init__(*args, **kwargs) self.fields['link_attributes'].widget = AttributesWidget()
def test_widget(self): widget = AttributesWidget() row = widget._render_row("test", "test", "test", "test", "test") # _render_row self.assertIn("attributes_key[test]", row) self.assertIn("attributes_value[test]", row) # render widget.render("name", None) widget.render("name", None, attrs="test") widget.render("name", {"test": "test"}) # value_from_datadict widget.value_from_datadict("", "", None) widget.value_omitted_from_data(None, None, None)