[Django] #33489: Autocomplete broken on ManyToManyField

21 views
Skip to first unread message

Django

unread,
Feb 3, 2022, 11:51:44 AM2/3/22
to django-...@googlegroups.com
#33489: Autocomplete broken on ManyToManyField
-----------------------------------------+------------------------
Reporter: Filipe | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
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've bumped into
https://github.com/django/django/blob/3.2.8/django/contrib/admin/views/autocomplete.py#L42
after upgrading from django 3.1.5 to 3.2.8 (introduced in 3.2 looking at
the tags, so adds up)

My current setup is a parent class:

{{{
# app "vulns"
class Finding(models.Model):
...
related_to = models.ManyToManyField('self', blank=True,
help_text='Other findings related to this one')

}}}

And then child class (adding for completeness but not sure it matters)

{{{
# app "burp"
class Finding(vuln_models.Finding):
...

}}}

`vulns.Finding` has an admin model defined with search fields `id` and
`title`

When editing a burp.Finding (changeform) the autocomplete for `related_to`
sends `related_to_rel+` as `field_name` resulting `self.source_field`
being set to the `ManyToManyRel` (not the `ManyToManyField`).

The Rel has `limit_choices_to` but it does not have a
`get_limit_choices_to` (while the Field does).

I've been trying to find if it's me doing something wrong in the model
definition but it's pretty straightforward...

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

Django

unread,
Feb 4, 2022, 1:06:53 AM2/4/22
to django-...@googlegroups.com
#33489: Autocomplete broken on ManyToManyField
-------------------------------+--------------------------------------
Reporter: Filipe | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo
* component: Uncategorized => contrib.admin
* type: Uncategorized => Bug


Comment:

Thanks for the report, however I cannot reproduce this issue with
described models. Can you provide a small sample project?

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

Django

unread,
Feb 4, 2022, 4:57:35 AM2/4/22
to django-...@googlegroups.com
#33489: Autocomplete broken on ManyToManyField
-------------------------------+--------------------------------------
Reporter: Filipe | Owner: nobody

Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Filipe):

So I've pushed a sample app but was also unable to reproduce. I'll try to
find the quirks in the original code and I'll update the ticket (if it's
not something in the project code/setup)

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

Django

unread,
Feb 4, 2022, 5:27:27 AM2/4/22
to django-...@googlegroups.com
#33489: Autocomplete broken on ManyToManyField
-------------------------------+--------------------------------------
Reporter: Filipe | Owner: nobody

Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Filipe):

ok, found the culprit line and it was not even in the custom theme, it was
directly in the project code...

Should've started a sample app from the start and would've saved some
bytes and bandwidth on this ticket :)

cheers

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

Django

unread,
Feb 4, 2022, 5:40:50 AM2/4/22
to django-...@googlegroups.com
#33489: Autocomplete broken on ManyToManyField
-------------------------------+--------------------------------------
Reporter: Filipe | Owner: nobody

Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* resolution: needsinfo => invalid


Comment:

Thanks for checking.

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

Reply all
Reply to author
Forward
0 new messages