mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #35044 -- Added Model.refresh_from_db(fields=...) test for clearing reverse relations.
This commit is contained in:
parent
2d3531af23
commit
0c690c6001
@ -966,6 +966,13 @@ class ModelRefreshTests(TestCase):
|
||||
article.refresh_from_db()
|
||||
self.assertTrue(hasattr(article, "featured"))
|
||||
|
||||
def test_refresh_clears_reverse_related_explicit_fields(self):
|
||||
article = Article.objects.create(headline="Test", pub_date=datetime(2024, 2, 4))
|
||||
self.assertFalse(hasattr(article, "featured"))
|
||||
FeaturedArticle.objects.create(article_id=article.pk)
|
||||
article.refresh_from_db(fields=["featured"])
|
||||
self.assertTrue(hasattr(article, "featured"))
|
||||
|
||||
def test_refresh_clears_one_to_one_field(self):
|
||||
article = Article.objects.create(
|
||||
headline="Parrot programs in Python",
|
||||
|
Loading…
Reference in New Issue
Block a user