本文整理汇总了Python中models.Article.was_published_today方法的典型用法代码示例。如果您正苦于以下问题:Python Article.was_published_today方法的具体用法?Python Article.was_published_today怎么用?Python Article.was_published_today使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Article
的用法示例。
在下文中一共展示了Article.was_published_today方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_methods
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import was_published_today [as 别名]
def test_custom_methods(self):
# Create a couple of Articles.
a = Article(id=None, headline='Area man programs in Python', pub_date=date(2005, 7, 27))
a.save()
b = Article(id=None, headline='Beatles reunite', pub_date=date(2005, 7, 27))
b.save()
# Test the custom methods.
self.assertFalse(a.was_published_today())
self.assertQuerysetEqual(a.articles_from_same_day_1(),
['<Article: Beatles reunite>'])
self.assertQuerysetEqual(a.articles_from_same_day_2(),
['<Article: Beatles reunite>'])
self.assertQuerysetEqual(b.articles_from_same_day_1(),
['<Article: Area man programs in Python>'])
self.assertQuerysetEqual(b.articles_from_same_day_2(),
['<Article: Area man programs in Python>'])