#33084: Incorrect warning W343 "limit_choices_to has no effect on 
ManyToManyField
with a through model"
-------------------------------------+-------------------------------------
               Reporter:  jhbuhrman  |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  limit_choices_to
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The model setup given below:

 {{{#!python
 class Number(models.Model):
     value = models.IntegerField()

     def __str__(self) -> str:
         return f"{self.value}"


 class NumbersToDiceThroughModel(models.Model):
     number = models.ForeignKey("Number", on_delete=models.PROTECT)
     die = models.ForeignKey("Die", on_delete=models.CASCADE)


 class Die(models.Model):
     numbers = models.ManyToManyField(
         "Number",
         through="NumbersToDiceThroughModel",
         limit_choices_to=models.Q(value__gte=1),
     )
 }}}

 Results in a **correct** limitation of possible choices. But at the same
 time the following warning is issued:

 {{{
 ... .Die.numbers: (fields.W343) limit_choices_to has no effect on
 ManyToManyField with a through model.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33084>
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/052.b882082ce5f16b057b0e0271e7777ceb%40djangoproject.com.

Reply via email to