#34345: Add system check for filter_horizontal/filter_vertical on
ManyToManyFields
with intermediary models.
--------------------------------------+------------------------------------
Reporter: David Pratten | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Mariusz Felisiak):
Replying to [comment:3 David Pratten]:
> Thanks. Sounds like a good outcome.
Would you like to prepare a patch via GitHub PR? The following should
work:
{{{#!diff
diff --git a/django/contrib/admin/checks.py
b/django/contrib/admin/checks.py
index 27537d9614..a844b3f16f 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -533,6 +533,16 @@ class BaseModelAdminChecks:
return must_be(
"a many-to-many field", option=label, obj=obj,
id="admin.E020"
)
+ elif not field.remote_field.through._meta.auto_created:
+ return [
+ checks.Error(
+ f"The value of '{label}' cannot include the
ManyToManyField "
+ f"'{field_name}', because that field manually
specifies a "
+ f"relationship model.",
+ obj=obj.__class__,
+ id="admin.E013",
+ )
+ ]
else:
return []
}}}
Tests and [https://docs.djangoproject.com/en/stable/ref/checks/#admin docs
changes] (in the `admin.E013` description) are also required.
--
Ticket URL: <https://code.djangoproject.com/ticket/34345#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701865e246baf-54ebc536-6ab9-4a98-b339-a678a86081ab-000000%40eu-central-1.amazonses.com.