def MovieDetail(request, pk): form = SearchMovieForm() if request.method == 'POST': form = SearchMovieForm(request.POST) if form.is_valid(): return HttpResponseRedirect( 'http://127.0.0.1:8000/library/movies/' + str(2)) movie = get_object_or_404(Movies, pk=pk) print(pk) cursor = connection.cursor() try: movie = cursor.execute( 'SELECT * FROM library_movies WHERE MovieID = ' + str(pk)) results = cursor.fetchall() print(results) finally: cursor.close() all = [] for row in results: dic = { 'MovieID': row[0], 'MovieTitle': row[1], 'MovieGenres': row[2], } all.append(dic) context = { 'movies': all, } return render(request, 'library/movies_detail.html', context=context)
def MovieDetail(request, pk): if request.method == 'POST': form = SearchMovieForm(request.POST) if form.is_valid(): return HttpResponseRedirect('http://127.0.0.1:8000/library/movies/'+str(2)) context = { 'form': form, } return render(request, 'library/movies_detail.html', context)
def MovieDetail(request, pk): if request.method == 'POST': form = SearchMovieForm(request.POST) if form.is_valid(): return HttpResponseRedirect( 'http://127.0.0.1:8000/library/movies/' + str(2))