class Article(models.Model): title = models.CharField() content = models.TextField() created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) I want to an article which was created and modified yesterday. And test the things today. from datetime import timedelta, datetime import mock class YesterdayTestCase(TestCase): def setUp(self): yesterday = datetime.now() - timedelta(days=1) with mock.patch('django.utils.timezone.now') as mock_now: mock_now.return_value = yesterday self.article = Article.objects.create( title = 'Article Title', content = 'Article Content' )
REF
Testing auto_now DateTime Fields in Django — Kogan.com Dev Blog