#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---------------------------------+------------------------------------
     Reporter:  sebastian_noack  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  contrib.admin    |                  Version:  1.2
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  1                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by olivierdalang):

 * has_patch:  0 => 1
 * needs_tests:  0 => 1


Comment:

 I had a look at the source. I see two places where this can be fixed :

 A. in django/db/models/base.py

 Model inheritance is created using OneToOneField but doesn't set the field
 to editable=False.
 This seems wrong, but at the same time, it seem to be consistent with
 regular primary keys, that for some reason don't set editable=False
 neither.
 The fix consists of settings editable=False on those fields.
 I'm not sure of the consequences of this, but this breaks potentially a
 lot of things.

 
https://github.com/olivierdalang/django/commit/a4ea0a021b784c5fbbecebed01f86c3987f1a8e9

 B. in django/contrib/admin/helpers.py

 There's a needs_explicit_pk_field() method which is exactly for that.
 The fix B consists of return True if the primary key is a OneToOneField.
 I guess this has much less consequences and is much safer.

 
https://github.com/olivierdalang/django/commit/fed7cd7f73f06a26f8a2eb8e867bdf4c81d4ae00


 What do you think ? For which fix should I open a PR ? Is there any chance
 this gets backported to 1.9 ?

--
Ticket URL: <https://code.djangoproject.com/ticket/15665#comment:10>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.5acd105ef344d3640d994b85fee109d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to