[Django] #29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields with a HiddenInput widget

8 views
Skip to first unread message

Django

unread,
Nov 17, 2018, 7:11:56 AM11/17/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde | Owner: nobody
Bultsma |
Type: Bug | Status: assigned
Component: | Version: 2.1
contrib.admin | Keywords: admin tabular
Severity: Normal | inline
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Setting the widget of an inline foreignkey field to `HiddenInput` in a
`TabularInline` does not hide the change-add-delete links in the form.
This bug does not appear when using a `StackInline` model admin.

**Code sample:**

models.py:
{{{#!python
from django.conf import settings
from django.db import models

class Parent(models.Model):
name = models.CharField(max_length=255)

class Child(models.Model):
parent = models.ForeignKey(Parent, on_delete=models.CASCADE)
name = models.CharField(max_length=255)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
}}}

admin.py:
{{{#!python
from django.contrib import admin
from django.forms import widgets
from .models import Parent, Child

class ChildInline(admin.TabularInline):
model = Child

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'user':
kwargs['initial'] = request.user.id
kwargs['widget'] = widgets.HiddenInput
return super().formfield_for_foreignkey(db_field, request,
**kwargs)

@admin.register(Parent)
class ParentAdmin(admin.ModelAdmin):
inlines = [ChildInline]
}}}

**Steps to reproduce the bug:**
1. Open the Django admin.
2. Add or change a parent. The change-add-delete links of the user field
in the tabular inline are visible and glitched at the start of each row:

[[Image(https://i.imgur.com/0eHQgmt.png)]]

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

Django

unread,
Nov 17, 2018, 7:13:09 AM11/17/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage:
inline | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Hidde Bultsma):

* owner: nobody => Hidde Bultsma


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

Django

unread,
Nov 17, 2018, 7:26:30 AM11/17/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage:
inline | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Are you able to determine if this is a regression (maybe by
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#bisecting-a-regression bisecting])?

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

Django

unread,
Nov 17, 2018, 7:42:08 AM11/17/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage:
inline | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Hidde Bultsma):

Replying to [comment:2 Claude Paroz]:


> Are you able to determine if this is a regression (maybe by
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#bisecting-a-regression bisecting])?

I will take a look at it.

--
Ticket URL: <https://code.djangoproject.com/ticket/29961#comment:3>

Django

unread,
Nov 17, 2018, 5:48:53 PM11/17/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage: Accepted
inline |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

I observed the same behavior as far back as I checked (Django 1.8), so if
it's a regression it's not a recent one. The extra links come from
[https://github.com/django/django/blob/f436c82637dafa3a9abbd65a3be77bf7ad431213/django/contrib/admin/options.py#L174-L176
RelatedFieldWidgetWrapper].

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

Django

unread,
Nov 18, 2018, 5:38:33 AM11/18/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage: Accepted
inline |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Hidde Bultsma):

Yeah, it looks like it has been there for at least since the admin was re-
factored in 1.0.

--
Ticket URL: <https://code.djangoproject.com/ticket/29961#comment:5>

Django

unread,
Nov 18, 2018, 7:21:13 AM11/18/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde

| Bultsma
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: admin tabular | Triage Stage: Accepted
inline |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Hidde Bultsma):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/10661 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29961#comment:6>

Django

unread,
Nov 20, 2018, 9:02:10 AM11/20/18
to django-...@googlegroups.com
#29961: Change-Add-Delete links are visible in tabular inline for foreignkey fields
with a HiddenInput widget
-------------------------------------+-------------------------------------
Reporter: Hidde Bultsma | Owner: Hidde
| Bultsma
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: fixed

Keywords: admin tabular | Triage Stage: Accepted
inline |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"89a2216486fa8a0513cbb1d49d2d587d4116c60b" 89a2216]:
{{{
#!CommitTicketReference repository=""
revision="89a2216486fa8a0513cbb1d49d2d587d4116c60b"
Fixed #29961 -- Made RelatedFieldWidgetWrapper hide related item links if
wrapping a hidden widget.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29961#comment:7>

Reply all
Reply to author
Forward
0 new messages