#2259: Primary keys should be readonly by default in admin
-------------------------------+--------------------------------------
     Reporter:  ed@…           |                    Owner:  Jason Hall
         Type:  Bug            |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  dev
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Comment (by Jason Hall):

 Just confirming this issue is still present in the current Django main
 branch.

 1. Editing a model with a non-integer primary key (e.g.,
 CharField(primary_key=True)) in the admin still renders the PK field as
 editable.
 2. Changing the PK silently inserts a new object, leaving the original
 untouched.

 This matches the original bug’s description — just without the SQL crash.

 I'm working on a patch to:

 1. Automatically add non-auto-created PKs to readonly_fields when editing
 in the admin.
 2. Preserve editability only during object creation.

 This aligns with the accepted design direction (see comments 23, 27, and
 28), and should prevent silent data corruption while respecting Django’s
 ORM design.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/2259#comment:53>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019844865797-3bf7debe-75f8-40ac-a90d-0168a83fcb15-000000%40eu-central-1.amazonses.com.

Reply via email to