I have a HTML template form:
<form action = "" method = "get">
<label for="movie_title">Filmo pavadinimas: </label>
<input type="text" name="movie_title">
<input type="submit" value="OK">
</form>
I want to enter the movie title on that form and get all of the actors that casted in that movie, but I don’t know how to get to that result even after reading the documentation. DB data:
Model for the required table:
class Filmlist(models.Model):
film_id = models.AutoField(primary_key=True)
title = models.CharField(max_length=250)
description = models.TextField(blank=True, null=True) # This field type is a guess.
category = models.CharField(max_length=250)
price = models.DecimalField(max_digits=10, decimal_places=5) # max_digits and decimal_places have been guessed, as this database handles decimal fields as float
length = models.SmallIntegerField(blank=True, null=True)
rating = models.CharField(blank=True, null=True, max_length=250)
name = models.CharField(max_length=250)
class Meta:
managed = False
db_table = 'film_list'
views file:
def aktoriai(request):
# print(request.GET)
objects = Filmlist.objects.filter(title=request.GET['movie_title'])
return render(request, "aktoriai.html", context={'objects': objects})
So to conclude, I have to enter movie title and get all of those actors show under actors row. Is it possible to do that with Django and HTML?