Using python and django provide full code, for the following problem: Write script that would fetch first_name
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 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.
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last