mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #19671 -- Added warnings that null and validators are ignored for ManyToManyField.
Thanks Loic Bistuer and Tim Graham for help and review.
This commit is contained in:
parent
3a85aae2ea
commit
011abb7d96
14 changed files with 76 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.checks import Error
|
||||
from django.core.checks import Error, Warning as DjangoWarning
|
||||
from django.db import models
|
||||
from django.test.utils import override_settings
|
||||
from django.test.testcases import skipIfDBFeature
|
||||
|
@ -60,6 +60,35 @@ class RelativeFieldTests(IsolatedModelsTestCase):
|
|||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
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=[''])
|
||||
|
||||
errors = ModelM2M.check()
|
||||
field = ModelM2M._meta.get_field('m2m')
|
||||
|
||||
expected = [
|
||||
DjangoWarning(
|
||||
'null has no effect on ManyToManyField.',
|
||||
hint=None,
|
||||
obj=field,
|
||||
id='fields.W340',
|
||||
)
|
||||
]
|
||||
expected.append(
|
||||
DjangoWarning(
|
||||
'ManyToManyField does not support validators.',
|
||||
hint=None,
|
||||
obj=field,
|
||||
id='fields.W341',
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_ambiguous_relationship_model(self):
|
||||
|
||||
class Person(models.Model):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue