[Django] #32728: Dupulicated column in admin site

2 views
Skip to first unread message

Django

unread,
May 7, 2021, 11:24:51 PM5/7/21
to django-...@googlegroups.com
#32728: Dupulicated column in admin site
-------------------------------------+-------------------------------------
Reporter: Greenbond | Owner: nobody
Type: Bug | Status: new
Component: | Version: 3.2
contrib.admin | Keywords: primary_key ,
Severity: Normal | list_editable
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
I found a suspicious bug in admin site.

Config ( Conditions )
1. You have a primary_key =True field in your model.py

2. Primary_key = True field is included in list_editable option in your
admins.py

The primary_key = True field you set in the list_editable will be
dupulicated in your admin site.

I created a public repository in github to test or check easily.
There is a screenshot for the suspicious bug and sample codings.

https://github.com/Greenbond/Bugreport

--
Ticket URL: <https://code.djangoproject.com/ticket/32728>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 7, 2021, 11:28:43 PM5/7/21
to django-...@googlegroups.com
#32728: Dupulicated column in admin site
-------------------------------------+-------------------------------------
Reporter: Greenbond | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:
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
-------------------------------------+-------------------------------------
Description changed by Greenbond:

Old description:

> I found a suspicious bug in admin site.
>
> Config ( Conditions )
> 1. You have a primary_key =True field in your model.py
>
> 2. Primary_key = True field is included in list_editable option in your
> admins.py
>
> The primary_key = True field you set in the list_editable will be
> dupulicated in your admin site.
>
> I created a public repository in github to test or check easily.
> There is a screenshot for the suspicious bug and sample codings.
>
> https://github.com/Greenbond/Bugreport

New description:

I found a suspicious bug in admin site.

Config ( Conditions )
1. You have a primary_key =True field in your model.py

2. Primary_key = True field is included in list_editable option in your
admins.py

The primary_key = True field you set in the list_editable will be
dupulicated in your admin site.

I created a public repository in github to test or check easily.

There is a screenshot for the suspicious bug and sample codings in the
Readme on github.

https://github.com/Greenbond/Bugreport

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32728#comment:1>

Django

unread,
May 7, 2021, 11:31:15 PM5/7/21
to django-...@googlegroups.com
#32728: Dupulicated column in admin site
-------------------------------------+-------------------------------------
Reporter: Greenbond | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:
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 Greenbond):

* cc: Greenbond (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/32728#comment:2>

Django

unread,
May 10, 2021, 1:34:34 AM5/10/21
to django-...@googlegroups.com
#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

unread,
Apr 25, 2022, 7:40:55 AM4/25/22
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"dcebc5da4831d2982b26d00a9480ad538b5c5acf" dcebc5da]:
{{{
#!CommitTicketReference repository=""
revision="dcebc5da4831d2982b26d00a9480ad538b5c5acf"
Refs #2259 -- Disallowed primary keys in ModelAdmin.list_editable.

Refs #32728.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32728#comment:4>

Reply all
Reply to author
Forward
0 new messages