#32728: Primary key column is duplicated in the admin changelist when it's in
ModelAdmin.list_editable.
-------------------------------------+-------------------------------------
     Reporter:  Greenbond            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  contrib.admin        |                  Version:  3.2
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:  primary_key ,        |             Triage Stage:
  list_editable                      |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Thanks for the report. Including primary keys in the
 `ModelAdmin.list_editable` will not work as you expect, see #2259. We
 could easily fix an issue with duplicated columns:
 {{{
 diff --git a/django/contrib/admin/templatetags/admin_list.py
 b/django/contrib/admin/templatetags/admin_list.py
 index 86eade6fed..69bbb53d94 100644
 --- a/django/contrib/admin/templatetags/admin_list.py
 +++ b/django/contrib/admin/templatetags/admin_list.py
 @@ -260,7 +260,7 @@ def items_for_result(cl, result, form):
                  bf = form[field_name]
                  result_repr = mark_safe(str(bf.errors) + str(bf))
              yield format_html('<td{}>{}</td>', row_class, result_repr)
 -    if form and not form[cl.model._meta.pk.name].is_hidden:
 +    if form and not form[cl.model._meta.pk.name].is_hidden and
 cl.model._meta.pk.name not in form.fields:
          yield format_html('<td>{}</td>', form[cl.model._meta.pk.name])
 }}}
 however it won't fix the main issue described in #2259. IMO including
 primary keys in `ModelAdmin.list_editable` should not be allowed. Closing
 as a duplicate of #2259.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32728#comment:3>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.aeef5bbab7348d4c92c5e83cfa3863fa%40djangoproject.com.

Reply via email to