Skip to content
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

Support for readonly fields #26

Open
filipefigcorreia opened this issue Nov 21, 2014 · 3 comments
Open

Support for readonly fields #26

filipefigcorreia opened this issue Nov 21, 2014 · 3 comments

Comments

@filipefigcorreia
Copy link

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.

@Aramgutang
Copy link
Contributor

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.

Aramgutang added a commit to ixc/django-multiselectfield that referenced this issue Feb 8, 2017
blag added a commit that referenced this issue Feb 21, 2017
A fix for field labels in the admin as decribed in my comment in issue #26
@blag
Copy link
Collaborator

blag commented Feb 28, 2017

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
  • Bach
  • Chopin

@gabn88
Copy link

gabn88 commented May 1, 2017

This would be really cool to have 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants