Conversation
list_to_class assigned the enclosing div's class attribute outright, so any class the widget's own template set was discarded. RadioSelectButtonGroup sets btn-group btn-group-toggle, which is what makes it a button group, so rendering it through bootstrap_field produced neither a button group nor plain radios, while data-toggle="buttons" survived and left Bootstrap's toggle JavaScript wired to nothing. The class is now added to what the widget already set. Django's RadioSelect and CheckboxSelectMultiple templates emit no class on that element, so output for every widget shipped with Django is byte-identical; only custom widget templates that set a class are affected, which is the case this fixes. The follow-up lookup of the same div by its new class string is gone too. It re-found the element that was already in hand and only worked as long as the class was assigned rather than appended. Fixes #894 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
list_to_classassigned the enclosing div's class attribute outright, so any class the widget's own template set was discarded.RadioSelectButtonGroupsetsbtn-group btn-group-toggle, which is what makes it a button group, so rendering it throughbootstrap_fieldproduced neither a button group nor plain radios.data-toggle="buttons"survived, because only the class was overwritten, leaving Bootstrap's toggle JavaScript wired to nothing.The class is now added to what the widget already set. Django's
RadioSelectandCheckboxSelectMultipletemplates emit no class on that element, so this is a no-op for every widget shipped with Django: I diffed the rendered output ofcategory1throughcategory4, at default and small size, and it is byte-identical. Onlycategory5, the custom widget, changes. There is a test for each half of that.I also dropped the follow-up
soup.find("div", {"class": classes}). It re-found the element already in hand, and it only worked as long as the class was assigned rather than appended, so it would have quietly stopped matching after this change.One thing this does not address: the enclosing div now reads
btn-group btn-group-toggle radio radio-success. Theradio radio-successpart is noise on a button group, but it is whatpost_widget_renderpasses for everyRadioSelectsubclass, and suppressing it per widget is a wider change than this fix.Fixes #894
🤖 Generated with Claude Code