def unpublished_post(user, session):
    new_post = BlogPost(author=user,
                        title=fake.sentence(),
                        content=fake.paragraph(),
                        is_published=False)
    session.add(new_post)
    session.commit()
    return new_post
def bunch_of_posts(user, session):
    for x in range(30):
        new_post = BlogPost(author=user,
                            title=fake.sentence(),
                            content=fake.paragraph(),
                            is_published=fake.boolean())
        session.add(new_post)
        new_post.comments.append(
            BlogComment(author=user, content=fake.paragraph()))
    session.commit()
Beispiel #3
0
from app import db, BlogPost

db.create_all()
# print("Initial BlogPosts : ",BlogPost.query().all())
# print("Initial BlogPosts : ",db.session.query().all())
db.session.add(BlogPost(title="BlogPost 1", content="c1", author="a1"))
print("BlogPosts after adding one : ", BlogPost.query().all())