def setUp(self): self.now = datetime.datetime.utcnow().replace(tzinfo=utc) self.timedelta = datetime.timedelta(15) author = User.objects.get(pk=1) for count in range(1, 11): post = Post(title=f"Post {count} Title", text="foo", author=author) if count < 6: pubdate = self.now - self.timedelta * count post.published_date = pubdate post.save()
def setUp(self): self.now = datetime.datetime.utcnow().replace(tzinfo=utc) self.timedelta = datetime.timedelta(15) author = User.objects.get(pk=1) for count in range(1, 11): post = Post(title='Post %d Title' % count, text='foo', author=author) if count < 6: #publish the first five posts pubdate = self.now - self.timedelta * count post.published_date = pubdate post.save()
def setUp(self): self.now = datetime.datetime.utcnow().replace(tzinfo=utc) self.timedelta= datetime.timedelta(15) author = User.objects.get(pk=1) for count in range(1,11): post = Post(title="Post %d Title" % count, text="foo", author=author) if count < 6: # publish the first five posts pubdate = self.now - self.timedelta * count post.published_date = pubdate post.save()
def setUp(self): self.now = datetime.datetime.utcnow().replace(tzinfo=utc) self.timedelta = datetime.timedelta(15) author = User.objects.get(pk=1) for count in range(1, 11): title = "Post %d Title" % count # print("NEXT TITLE:", title) post = Post(title="Post %d Title" % count, text="foo", author=author) if count < 6: # print("setting published date") # create 5 records with a published date pubdate = self.now - self.timedelta * count post.published_date = pubdate post.save()
def setUp(self): self.now = datetime.datetime.utcnow().replace(tzinfo=utc) self.timedelta = datetime.timedelta(15) author = User.objects.get(pk=1) self.category = Category(name='A Category') self.category.save() for count in range(1,11): post = Post(title="Post %d Title" % count, text="foo", author=author) if count < 6: # publish the first five posts pubdate = self.now - self.timedelta * count post.published_date = pubdate post.save() if bool(count & 1): # put odd items in category: self.category.posts.add(post)