def add_twit(): form = addTwitForm() if form.validate_on_submit(): twit = form.twit.data db.add_twit(twit, session['user_id']) return redirect(vs_url_for('index')) return render_template('add_twit_mysql.html', form=form)
def add_twit(): form = addTwitForm() if form.validate_on_submit(): twit = form.twit.data user_id = current_user.user_id db.add_twit(twit, user_id) return redirect(vs_url_for('.index')) return render_template('add_twit_mysql.html', form=form)
def add_twit(): form = addTwitForm() if form.validate_on_submit(): twit = form.twit.data user_id = current_user.user_id new_twit = Twits(twit=twit, user_id=user_id) db.session.add(new_twit) db.session.commit() return redirect(vs_url_for('index')) return render_template('add_twits.html', form=form)
def add_twit(): form = addTwitForm() if form.validate_on_submit(): twit = form.twit.data user_id = current_user.user_id new_twit = Twits(twit=twit, user_id=user_id) # we need to add the object to the flask-sqlalchemy session # and then commit our changes for it to be inserted in to the database db.session.add(new_twit) db.session.commit() return redirect(vs_url_for('index')) return render_template('add_twit_mysql.html', form=form)
def add_twit(): form = addTwitForm() if form.validate_on_submit(): twit = form.twit.data user_id = current_user.user_id # SQLAlchemy adds an implicit constructor to all model classes which # accepts keyword arguments for all its columns and relationships. # We can use this to create our new twit new_twit = Twits(twit=twit, user_id=user_id) # As explained in http://flask-sqlalchemy.pocoo.org/2.3/queries/ # we need to add the object to the flask-sqlalchemy session # and then commit our changes # for it to be inserted in to the database db.session.add(new_twit) db.session.commit() return redirect(vs_url_for('index')) return render_template('add_twit_mysql.html',form=form)