mirror of
https://github.com/django/django.git
synced 2025-07-31 00:54:37 +00:00
Fixed #31596 -- Changed ForeignKey.validate() to use the base manager.
This commit is contained in:
parent
1e96de4f97
commit
e13cfc6dfd
6 changed files with 77 additions and 1 deletions
|
@ -48,6 +48,13 @@ class BaseModelValidationTests(ValidationAssertions, TestCase):
|
|||
mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk)
|
||||
self.assertFailsValidation(mtv.full_clean, ['parent'])
|
||||
|
||||
def test_FK_validates_using_base_manager(self):
|
||||
# Archived articles are not available through the default manager, only
|
||||
# the base manager.
|
||||
author = Author.objects.create(name="Randy", archived=True)
|
||||
article = Article(title='My Article', author=author)
|
||||
self.assertIsNone(article.full_clean())
|
||||
|
||||
def test_wrong_email_value_raises_error(self):
|
||||
mtv = ModelToValidate(number=10, name='Some Name', email='not-an-email')
|
||||
self.assertFailsValidation(mtv.full_clean, ['email'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue