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.
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>
* cc: Greenbond (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/32728#comment:2>
* 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>
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>