def add(): form = MoviesForm() if form.validate_on_submit(): new_movie = Movies(name=form.name.data) db.session.add(new_movie) db.session.commit() return redirect(url_for('index')) return render_template('add.html', form=form)
def insert_movie(): form = MovieForm() if form.validate_on_submit(): movieData = Movies(title=form.title.data, release_year=form.release_year.data) db.session.add(movieData) db.session.commit() return redirect(url_for('all_movie')) else: print(form.errors) return render_template('insert_movie.html', title='Add Movie', form=form)
def add(): form = addMovie() if form.validate_on_submit(): addmovie = Movies(title=form.title.data, genre=form.genre.data, director=form.director.data, rating=form.rating.data, author=current_user) db.session.add(addmovie) db.session.commit() return redirect(url_for('movies')) else: print(form.errors) return render_template('add.html', title='Add', posts=addMovie, form=form)
def dost(): form = MovieForm() if form.validate_on_submit(): postData2 = Movies(movie_name=form.movie_name.data, director_name=form.director_name.data, genre=form.genre.data, short_content=form.short_content.data, book_id=form.book_id.data) db.session.add(postData2) db.session.commit() return redirect(url_for('movie')) else: print(form.errors) return render_template('dost.html', title='Dost', form=form)
def setUp(self): # this will be called every time we run a test # ensure there is no data in the test database when the test starts db.session.commit() db.drop_all() db.create_all() #creates a test entry for the movies table movie = Movies(title="Test Movie!", release_year=2000) #creates a test entry for the actor tables actor = Actors(first_name="Jonny", last_name="Depp", date_of_birth='1955-01-01') #creates test entry for cast details cast = Cast_details(movie_id=1, actor_id=1) db.session.add(movie) db.session.add(actor) db.session.commit() db.session.add(cast) db.session.commit()
from application import db from application.models import Movies db.drop_all() db.create_all() new_movie = Movies(movie="Citizen Kane, Thriller, Orson Welles: ") db.session.add(new_movie) db.session.commit()