#34345: Add system check for filter_horizontal/filter_vertical on 
ManyToManyFields
with intermediary models.
-------------------------------------+-------------------------------------
     Reporter:  David Pratten        |                    Owner:  David
         Type:                       |  Pratten
  Cleanup/optimization               |                   Status:  assigned
    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 David Pratten):

 Replying to [comment:4 Mariusz Felisiak]:

 I'm happy to work through this, but it won't be quick.

 - Are we redefining {{{admin.E013}}} there seems to already be a
 description of this error?
 - Could you direct me to an explanation of where the documentation for the
 errors is held and how it is updated?
 - Could you direct me to an explanation of how to add a test case?

 Thanks

 > 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:6>
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/010701865ecd73a4-623dbd19-6bda-493a-b820-578706ff9efd-000000%40eu-central-1.amazonses.com.

Reply via email to