A typical use case is a ModelForm where you'd like to disable some fields
while still displaying all values. So currently, if you simply add
`disabled` to the widget attributes, you'll have a problem: the form will
clear the field as the value is not present in the data (and the field is
not in excluded fields).
--
Ticket URL: <https://code.djangoproject.com/ticket/25078>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: 0 => 1
* has_patch: 0 => 1
Comment:
POC pull request: https://github.com/django/django/pull/4958
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:1>
* stage: Unreviewed => Accepted
Comment:
I'd suggest to write to the mailing list to get some ideas for this. An
implementation that reduces the amount of admin-specific code needed for
`ModelAdmin.readonly_fields` might be interesting (#342 / [bcd9482a20]).
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:2>
Comment (by claudep):
`ModelAdmin.readonly_fields` has chosen another route, that is displaying
the value of the field instead of displaying a disabled form widget
containing the value. I can write to the mailing list, but I'm not sure
about what sort of ideas I would ask for.
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:3>
Comment (by timgraham):
Do you prefer or require disabled form widgets as opposed to displaying
the values? Just curious.
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:4>
Comment (by claudep):
Displaying a value is triggering a whole different machinery, as the
`readonly_fields` admin patch shows. I think what we address in this issue
is a lot simpler as we simply rely on a HTML attribute. I think that
displaying the disabled form widget makes sense as we are still in the
context of displaying a form, but for whatever reason, some field is not
editable by the current user.
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:5>
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:7>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"1ef4aeab403f7fb74c0b9b11fde854fd03afc40c" 1ef4aeab]:
{{{
#!CommitTicketReference repository=""
revision="1ef4aeab403f7fb74c0b9b11fde854fd03afc40c"
Fixed #25078 -- Added support for disabled form fields
Thanks Keryn Knight and Tim Graham for the reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:8>