1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #33084 -- Removed incorrect system check for ManyToManyField with limit_choices_to.

This commit is contained in:
Hasan Ramezani
2021-09-08 13:57:49 +02:00
committed by Mariusz Felisiak
parent 46c8df640c
commit 0a28b42b15
6 changed files with 34 additions and 45 deletions

View File

@@ -81,32 +81,12 @@ class RelativeFieldTests(SimpleTestCase):
field = Model._meta.get_field('m2m')
self.assertEqual(field.check(from_model=Model), [])
def test_many_to_many_with_limit_choices_auto_created_no_warning(self):
class Model(models.Model):
name = models.CharField(max_length=20)
class ModelM2M(models.Model):
m2m = models.ManyToManyField(Model, limit_choices_to={'name': 'test_name'})
self.assertEqual(ModelM2M.check(), [])
def test_many_to_many_with_useless_options(self):
class Model(models.Model):
name = models.CharField(max_length=20)
class ModelM2M(models.Model):
m2m = models.ManyToManyField(
Model,
null=True,
validators=[lambda x: x],
limit_choices_to={'name': 'test_name'},
through='ThroughModel',
through_fields=('modelm2m', 'model'),
)
class ThroughModel(models.Model):
model = models.ForeignKey('Model', models.CASCADE)
modelm2m = models.ForeignKey('ModelM2M', models.CASCADE)
m2m = models.ManyToManyField(Model, null=True, validators=[lambda x: x])
field = ModelM2M._meta.get_field('m2m')
self.assertEqual(ModelM2M.check(), [
@@ -120,12 +100,6 @@ class RelativeFieldTests(SimpleTestCase):
obj=field,
id='fields.W341',
),
DjangoWarning(
'limit_choices_to has no effect on ManyToManyField '
'with a through model.',
obj=field,
id='fields.W343',
),
])
def test_many_to_many_with_useless_related_name(self):