Changes between Initial Version and Version 1 of Ticket #2259, comment 26


Ignore:
Timestamp:
Nov 3, 2013, 2:38:31 PM (10 years ago)
Author:
Bouke Haarsma

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2259, comment 26

    initial v1  
    11After 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.
    22
    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.
     3Another 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.
    44
    55The 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.
Back to Top