Repository: zostera/django-bootstrap3

Issue:
Inline radio buttons and checkboxes lack spacing
Introduced in 23.3.

<img width="278" alt="Scherm­afbeelding 2023-06-28 om 05 40 33" src="https://github.com/zostera/django-bootstrap3/assets/82315/e3ce7026-8973-4adb-8f89-69f7aa188ebe">



Discussion:
Caused by a difference in spacing between tags when rendering in `Django<4` vs `Django>=4`. In inline mode, spacing between tags becomes relevant.

Solution is to add this "inline relevant spacing".

Resolving patch:
diff --git a/src/bootstrap3/__about__.py b/src/bootstrap3/__about__.py
--- a/src/bootstrap3/__about__.py
+++ b/src/bootstrap3/__about__.py
@@ -1 +1 @@
-__version__ = "23.3"
+__version__ = "23.4.dev0"
diff --git a/src/bootstrap3/renderers.py b/src/bootstrap3/renderers.py
--- a/src/bootstrap3/renderers.py
+++ b/src/bootstrap3/renderers.py
@@ -315,7 +315,7 @@ def list_to_class(self, html, klass):
         classes = add_css_class(klass, self.get_size_class())
         if IS_PRE_DJANGO4:
             return self._list_to_class_pre_django4(html, classes)
-        return re.sub("<div>\s*<label", f'<div class="{classes}"><label', html)
+        return re.sub("\s*<div>\s*<label", f' <div class="{classes}"><label', html)
 
     def _list_to_class_pre_django4(self, html, classes):
         return (


Test patch:
diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py
--- a/tests/test_templatetags.py
+++ b/tests/test_templatetags.py
@@ -530,19 +530,21 @@ def test_radioset_inline(self):
         res = render_template_with_form("{% bootstrap_form form layout='inline' %}", {"form": form})
         expected = """
             <div class="form-group bootstrap3-req">
-            <label class="sr-only">Radio</label>
-            <div id="id_radio">
-            <div class="radio">
-            <label for="id_radio_0">
-            <input type="radio" name="radio" value="1" class="" title="" required id="id_radio_0">Radio 1
-            </label>
-            </div>
-            <div class="radio">
-            <label for="id_radio_1">
-            <input type="radio" name="radio" value="2" class="" title="" required id="id_radio_1">Radio 2
-            </label>
-            </div>
-            </div>
+              <label class="sr-only">Radio</label>
+              <div id="id_radio">
+                <div class="radio">
+                  <label for="id_radio_0">
+                    <input type="radio" name="radio" value="1" class="" title="" required id="id_radio_0">
+                    Radio 1
+                  </label>
+                </div>
+                <div class="radio">
+                  <label for="id_radio_1">
+                    <input type="radio" name="radio" value="2" class="" title="" required id="id_radio_1">
+                    Radio 2
+                  </label>
+                </div>
+              </div>
             </div>
             """
         if IS_PRE_DJANGO4:
@@ -551,3 +553,4 @@ def test_radioset_inline(self):
                 '<label class="sr-only" for="id_radio_0">Radio</label>',
             )
         self.assertHTMLEqual(res, expected)
+        self.assertIn(' <div class="radio">', res, msg="Missing relevant whitespace for inline rendering.")