[Django] #33669: Bug in contrib/admin/templatetags/admin_modify.py

5 views
Skip to first unread message

Django

unread,
Apr 28, 2022, 10:01:38 AM4/28/22
to django-...@googlegroups.com
#33669: Bug in contrib/admin/templatetags/admin_modify.py
-------------------------------------------+------------------------
Reporter: rezazeiny | Owner: (none)
Type: Bug | Status: new
Component: Error reporting | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
I have a bug in function cell_count in file
django/contrib/admin/templatetags/admin_modify.py

please check type of field_data if this is dictionary this can not call
with dot.

I fixed it and over write in my code. my code is:
{{{

@register.filter
def cell_count(inline_admin_form):
"""Return the number of cells used in a tabular inline."""
count = 1 # Hidden cell with hidden 'id' field
for fieldset in inline_admin_form:
# Count all visible fields.
for line in fieldset:
for field in line:
field_data = field.field
if type(field_data) == dict:
is_hidden = field_data["is_hidden"]
else:
is_hidden = field_data.is_hidden
if not is_hidden:
count += 1
if inline_admin_form.formset.can_delete:
# Delete checkbox
count += 1
return count
}}}

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

Reply all
Reply to author
Forward
0 new messages