Re: [Django] #34345: filter_horizontal and filter_vertical don't work with through (was: filter_horizontal and filter_vertical don't work with through - limitation not documented)

41 views
Skip to first unread message

Django

unread,
Feb 17, 2023, 12:25:40 AM2/17/23
to django-...@googlegroups.com
#34345: filter_horizontal and filter_vertical don't work with through
-------------------------------------+-------------------------------------
Reporter: David Pratten | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 4.1
Severity: Normal | Resolution:
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):

* keywords: Gotcha =>
* type: Bug => Cleanup/optimization
* easy: 1 => 0


Comment:

> Neither of
>
> -
https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal
and
> -
https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_vertical
>
> call out the requirement to **not** use
> {{{
> ManyToManyField(through="")
> }}}

There is a separate section in the same docs that describes
[https://docs.djangoproject.com/en/stable/ref/contrib/admin/#working-with-
many-to-many-intermediary-models Working with many-to-many intermediary
models]. I don't think it is necessary to cross-refer this section in all
places where `ManyToManyField` is mentioned.

> In the same way:
> -
https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.ManyToManyField.through
>
> doesn't call out the consequence that filter_horizontal and
filter_vertical will stop working if one goes down the pathway of:
>
> {{{
> ManyToManyField(through="")
> }}}

Models docs are not the right place to describe how contrib apps work.

-----

What do you think about changing `admin.E020` to:
> "The value of `filter_vertical[n]/filter_horizontal[n]` must be a many-
to-many field without a `through` model.
and raising a system check in this case?

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

Reply all
Reply to author
Forward
0 new messages