New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #13009 -- Added BoundField.widget_type property. #12656
Conversation
I'm not so much thrilled by this new load of new template filters. What about a new |
I've updated this to add a new property to I think the filter approach gives a better result in the templates. i.e. I think that 1) is better than 2)
However, from a Django perspective the second option is by far a cleaner implementation and has the benefit of working with custom widgets. The filter method; however is, well, a little repetitive. So for me, it's a trade off between a better experience for users building their templates vs impact on Django code base. On the current version, the tests need moving to a better home, but I'm not quite sure where they are best placed. Appreciate some guidance on this. |
@smithdc1 I agree with Claude. I would chop new (one-line) filters and limit this change to the new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I squashed, rebased, and pushed a fixup with some suggested edits.
- Removed the docstring from
widget_type
. I didn't think the full example appropriate there, and by the time I'd removed that, it just repeated the single code line, so... - Moved the tests with the other
boundfield
tests intest_forms
. - Some small rewording edits.
This LGTM. 👍 Thanks @smithdc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks y'all 👍 |
Ticket
The issue explained in the ticket of rendering fields (widgets, really) dependant upon their type is a key part of
crispy-forms
. This project solved it by adding a limited number of filters so you can do something like this.I've replicated that approach here, and for completeness I've added a filter for each of the widget types, added tests and docs.
There are comments on the ticket about
multifield
(multiwidget). I think for now just knowing it is amultiwidget
is enough. Over at crispy-forms the project still hasn't found a way to deal with these widgets and all their complexities.Appreciate your thoughts on this one.