Changes between Initial Version and Version 1 of Ticket #2259, comment 26
- Timestamp:
- Nov 3, 2013, 2:38:31 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #2259, comment 26
initial v1 1 1 After diving into the logic responsible for generating the form, I suspect that ModelForm generates the disputed form field. So it appears that the fix should be in ModelForm, which shouldn't generate an editable field for primary keys in the first place. However, then one wouldn't be able to create a new instance from the admin as the non-editable field is mandatory. 2 2 3 Another possibility would be to alter ` `ModelAdmin.get_readonly_fields`` to return the primary key field for existing instances. Somewhat like below, although that makes the normally hidden primary key fields visible as well.3 Another possibility would be to alter `ModelAdmin.get_readonly_fields` to return the primary key field for existing instances. Somewhat like below, although that makes the normally hidden primary key fields visible as well. 4 4 5 5 The first would be the most consistent solution; primary key fields never editable. It would be up to the developers to dynamically add the primary key field back in if needed.