def create_genre(): form = GenreForm() if form.validate_on_submit(): new_genre = Genre(name=form.name.data) db.session.add(new_genre) db.session.commit() flash("New genre was created successfully.") return redirect(url_for("main.homepage")) return render_template("create_genre.html", form=form)
def create_genre(): gf = GenreForm() if gf.genre_form_submit.data and gf.validate_on_submit(): genre = Genre(name=gf.name.data) db.session.add(genre) db.session.commit() # fields return render_template('create_genre.html', gf=gf)
def create_genre(): genreForm = GenreForm() if genreForm.validate_on_submit(): new_genre = Genre(name=genreForm.name) db.session.add(new_genre) db.session.commit() flash('Success') return redirect('main.homepage') return render_template('create_genre.html', genreForm=genreForm)
def create_genre(): form = GenreForm() if form.validate_on_submit(): new_genre = Genre(name=form.name.data) db.session.add(new_genre) db.session.commit() flash('New genre created successfully.') return redirect(url_for('main.homepage')) # if form was not valid, or was not submitted yet return render_template('create_genre.html', form=form)
def create_genre(): # : Make a GenreForm instance form = GenreForm() # : If the form was submitted and is valid, create a new Genre object # and save to the database, then flash a success message to the user and # redirect to the homepage if form.validate_on_submit(): new_genre = Genre(name=form.genre.data) db.session.add(new_genre) db.session.commit() # : Send the form object to the template, and use it to render the form # fields return redirect(url_for('main.create_genre', genre=new_genre)) return render_template('create_genre.html', form=form)
def create_genre(): # TODO: Make a GenreForm instance form = GenreForm() # TODO: If the form was submitted and is valid, create a new Genre object # and save to the database, then flash a success message to the user and # redirect to the homepage if form.validate_on_submit(): new_genre = Genre(name=form.name.data) db.session.add(new_genre) db.session.commit() flash('New genre was created successfully.') # TODO: Send the form object to the template, and use it to render the form # fields return render_template('create_genre.html', form=form)