Repository: zostera/django-bootstrap3

Issue:
addon_before addon_after EmailInput not showing (django 1.11b1 python 3.5)
Need to modify renderes.py line 439 to also check for EmailInput

    def make_input_group(self, html):
        if (self.addon_before or self.addon_after) and isinstance(self.widget, (TextInput, DateInput, Select, EmailInput)):

Thanks!


Discussion:

Resolving patch:
diff --git a/bootstrap3/renderers.py b/bootstrap3/renderers.py
--- a/bootstrap3/renderers.py
+++ b/bootstrap3/renderers.py
@@ -8,8 +8,8 @@
     ReadOnlyPasswordHashWidget = None
 
 from django.forms import (
-    TextInput, DateInput, FileInput, CheckboxInput, MultiWidget,
-    ClearableFileInput, Select, RadioSelect, CheckboxSelectMultiple
+    TextInput, DateInput, FileInput, CheckboxInput, MultiWidget, ClearableFileInput,
+    Select, RadioSelect, CheckboxSelectMultiple, NumberInput, EmailInput, URLInput
 )
 # Django 1.9 moved SelectDateWidget to django.forms.widget from
 # django.forms.extras. Django 2.0 will remove the old import location.
@@ -443,7 +443,8 @@ def wrap_widget(self, html):
         return html
 
     def make_input_group(self, html):
-        if (self.addon_before or self.addon_after) and isinstance(self.widget, (TextInput, DateInput, Select)):
+        if (self.addon_before or self.addon_after) and isinstance(
+                self.widget, (TextInput, NumberInput, EmailInput, URLInput, DateInput, Select)):
             before = '<span class="{input_class}">{addon}</span>'.format(
                 input_class=self.addon_before_class, addon=self.addon_before) if self.addon_before else ''
             after = '<span class="{input_class}">{addon}</span>'.format(


Test patch:
diff --git a/bootstrap3/tests.py b/bootstrap3/tests.py
--- a/bootstrap3/tests.py
+++ b/bootstrap3/tests.py
@@ -88,6 +88,8 @@ class TestForm(forms.Form):
         widget=forms.CheckboxSelectMultiple,
         help_text='Check as many as you like.',
     )
+    number = forms.FloatField()
+    url = forms.URLField()
     addon = forms.CharField(
         widget=forms.TextInput(attrs={'addon_before': 'before', 'addon_after': 'after'}),
     )
@@ -715,3 +717,38 @@ class ShowPlaceholderTest(TestCase):
     def test_placeholder_set_from_label(self):
         res = render_form_field('sender')
         self.assertIn('placeholder="Sender © unicode"', res)
+
+
+class ShowAddonsTest(TestCase):
+
+    def assertFieldHasAddons(self, field):
+        """Asserts that a given field has an after and before addon."""
+        addon_before = "bf"
+        addon_after = "af"
+
+        res = render_template_with_form(
+            '{{% bootstrap_field form.{0} addon_before="{1}"  addon_after="{2}" %}}'.format(
+                field, addon_before, addon_after)
+        )
+
+        self.assertIn('class="input-group"', res)
+        self.assertIn('class="input-group-addon">{0}'.format(addon_before), res)
+        self.assertIn('class="input-group-addon">{0}'.format(addon_after), res)
+
+    def test_show_addons_textinput(self):
+        self.assertFieldHasAddons("subject")
+
+    def test_show_addons_select(self):
+        self.assertFieldHasAddons("select1")
+
+    def test_show_addons_dateinput(self):
+        self.assertFieldHasAddons("date")
+
+    def test_show_addons_email(self):
+        self.assertFieldHasAddons("sender")
+
+    def test_show_addons_number(self):
+        self.assertFieldHasAddons("number")
+
+    def test_show_addons_url(self):
+        self.assertFieldHasAddons("url")