Question
Using python and django provide full code, for the following problem: Write script that would fetch first_name and last_name from the Actor table, based on
Using python and django provide full code, for the following problem:
Write script that would fetch first_name and last_name from the Actor table, based on the actor_id and film_id from the FilmActor table and film_id from the Film table.
Use foreign and primary keys to complete the task. You cannot use SQL queries !!!!!
Provide models.py, views.py and .html files.
The code below fetches the name of the movie that the user has entered.
def search_films(request):
films = Film.objects.all()
if request.method == "POST":
userinput= request.POST['userinput']
films = Film.objects.filter(title__contains=userinput)
return render(request, 'search.html',
{'userinput':userinput,
'films':films,
})
else:
return render(request, 'search.html',
{})
Expected result: User inputs name of the movie and gets the corresponding first and last name of the actors starring in that movie.
actor id film id last update actor id 1 1 1 2019-04-11 18:11:48 1 first name 1 PENELOPE last name last update film id title GUINESS 2019-04-11 18:11:48 1 1 ACADEMY DINOSAUR 2 1 23 2019-04-11 18:11:48 2 2 NICK WAHLBERG 2019-04-11 18:11:48 2 2 ACE GOLDFINGER 3 1 25 2019-04-11 18:11:48 3 3 ED 4 1 106 2019-04-11 18:11:48 4 4 JENNIFER CHASE DAVIS 2019-04-11 18:11:48 3 3 ADAPTATION HOLES 2019-04-11 18:11:48 4 4 AFFAIR PREJUDICE 5 1 140 2019-04-11 18:11:48 5 5 JOHNNY 6 1 166 2019-04-11 18:11:48 6 6 BETTE 7 1 277 2019-04-11 18:11:48 7 7 GRACE LOLLOBRIGIDA NICHOLSON MOSTEL 2019-04-11 18:11:48 5 5 AFRICAN EGG 2019-04-11 18:11:48 6 6 AGENT TRUMAN 2019-04-11 18:11:48 7 7 AIRPLANE SIERRA 8 1 361 2019-04-11 18:11:48 8 8 MATTHEW 9 1 438 2019-04-11 18:11:48 9 9 JOE 10 1 499 2019-04-11 18:11:48 10 10 CHRISTIAN JOHANSSON SWANK GABLE 2019-04-11 18:11:48 8 8 AIRPORT POLLOCK 2019-04-11 18:11:48 9 9 ALABAMA DEVIL 2019-04-11 18:11:48 10 10 ALADDIN CALENDAR 11 1 506 2019-04-11 18:11:48 11 11 ZERO CAGE 12 1 509 2019-04-11 18:11:48 12 12 KARL BERRY 2019-04-11 18:11:48 2019-04-11 18:11:48 11 11 ALAMO VIDEOTAPE 12 12 ALASKA PHANTOM 13 1 605 2019-04-11 18:11:48 13 14 1 635 2019-04-11 18:11:48 14 15 1 749 2019-04-11 18:11:48 15 13 UMA 14 VIVIEN 15 CUBA WOOD 2019-04-11 18:11:48 13 13 ALI FOREVER BERGEN 2019-04-11 18:11:48 14 14 ALICE FANTASIA 16 1 832 2019-04-11 18:11:48 16 16 FRED OLIVIER COSTNER 2019-04-11 18:11:48 15 15 ALIEN CENTER 2019-04-11 18:11:48 Film table Film actor table Actor table
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started