django-multiselectfield
django-multiselectfield copied to clipboard
Support for readonly fields
When making a MultiSelectField readonly (e.g., via de readonly_fields
attribute), it gets rendered in the admin as a repr()
of a python list. Would be great to make it a little more user-friendly.
This can be worked around by using get_FIELDNAME_display
in the readonly_fields
list (though as a side-effect, it will always appear at the bottom of the form, unless you want to muck around with overriding get_fields
and similar on the ModelAdmin class). However, the label for the field will be broken. I'll put through a pull request shortly that fixes the label issue; it's probably a change that will come in handy for a future proper fix as well.
Can you explain a little bit more how you think this should be rendered when its a readonly field? I adjusted how the field is displayed in commit 01dcad2
(currently awaiting testing in the master
branch) and that may be more to your liking. See this comment for how it renders in the admin list_display
and list_filter
now.
The only other good way I can think to display this is as a list of disabled checkboxes of all choices where the checkbox is checked for choices in the list and unchecked if not. Example:
Possible choices are Beethoven, Bach, and Chopin, only Bach and Chopin are selected:
- [ ] Beethoven
- [x] Bach
- [x] Chopin
This would be really cool to have 👍