#33084: Removed incorrect fields.W343 check and notes about limit_choices_to
restrictions for ManyToManyField.
-------------------------------------+-------------------------------------
     Reporter:  jhbuhrman            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  limit_choices_to     |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Carlton Gibson, Simon Charette (added)
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for the report!

 I'm puzzled. I checked with a sample project and the following test:
 {{{
 class MyTests(TestCase):
     def test_limit_choices_through(self):
         for i in range(-10, 10):
             Number.objects.create(value=i)

         class CharacterDetailsForm(forms.ModelForm):
             class Meta:
                 model = Die
                 fields = ['numbers']

         self.assertEqual(Number.objects.count(), 20)

         form = CharacterDetailsForm()
         self.assertEqual(form.fields['numbers'].queryset.count(), 9)
 self.assertEqual(form.fields['numbers'].queryset.filter(value__lt=1).count(),
 0)
 }}}
 and `limit_choices_to` works since at least Django 1.1 (yes **1.1**, I
 really tried to find when it wasn't working).

 It seems that this check is incorrect since its introduction in
 ba53da894fc713629ae4d3fbdd14eff98c808389 (see #26796) and the
 
[https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.ManyToManyField.limit_choices_to
 related note] in docs is also incorrect since its introduction in
 c6c25adf6d9f71ea11f61392f6f3d221f01e5216 (see #9733).

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33084#comment:1>
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/067.3f77fbe794579695d823498d3463d9e1%40djangoproject.com.

Reply via email to