def store(): # Create new post post = Post(request.form['message']) # Commit new post to db post.save() # Respond with completed post object return json.dumps(post.json)
def add_post_proc(): form = PostAddForm() #if form.validate_on_submit(): user = User.objects(id=current_user.id).get() post = Post( title=form.title.data, tag=form.tag.data, text=form.text.data, urls=form.url.data.split(), user=user, ) post.save() flash('Add post') return redirect(url_for("posts.index")) #redirect(get_redirect_target())
def setUpTestData(cls): socialmedia = SocialMedia(socialmedia="linkedin") socialmedia.save() author = User.objects.create_user( username="******", email="*****@*****.**", password="******", ) author.save() post = Post( body="Mon post de test", author=author, schedule_time="2021-09-07 09:23", ) post.save() print(post.id) post.socialmedia.add(socialmedia.id)