<div>
containing form:-
I will make all anchor tags in the form into the options of a single radio.
<div class="font-sans-serif btn-reveal-trigger position-static ">
<button class="list-change-button btn btn-sm dropdown-caret-none transition-none btn-reveal fs--2"
type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true"
aria-expanded="false" data-bs-reference="parent">
<svg class="" width="2rem" height="2rem" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M12.0049 16.005L12.0049 15.995" stroke="#323232" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M12.0049 12.005L12.0049 11.995" stroke="#323232" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M12.0049 8.005L12.0049 7.995" stroke="#323232" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path
d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z"
stroke="#323232" stroke-width="2" />
</svg>
</button>
<form action="/" method="post">
<div class="dropdown-menu dropdown-menu-end py-2" style="">
<a class="dropdown-item" href="#">Currently Watching</a>
<a class="dropdown-item" href="#">On Hold</a>
<a class="dropdown-item" href="#">Plan to Watch</a>
<a class="dropdown-item" href="#">Completed</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="#!">Remove from Watchlist</a>
</div>
</form>
</div>
models.py:-
class Watchlist(models.Model):
list_name = models.CharField(max_length=20)
def __str__(self):
return self.list_name
class Movie(models.Model):
title = models.CharField(max_length=255)
release_year = models.PositiveIntegerField(validators=[
MinValueValidator(1900),
MaxValueValidator(2100),
])
duration_in_min = models.PositiveSmallIntegerField()
imdb_rating = models.DecimalField(max_digits=2, decimal_places=1)
rotten_tomatoes_score = models.PositiveSmallIntegerField(validators=[
MinValueValidator(1),
MaxValueValidator(100)
])
cover_img = models.ImageField(upload_to="cover_images")
tags = models.ManyToManyField(Tag)
watchlist = models.ForeignKey(Watchlist, on_delete=models.SET_NULL, null=True, blank=True, related_name="movies")
def __str__(self):
return self.title
views.py:-
def index(req):
movies = Movie.objects.all()
return render(req, "movies/index.html", {
"movies_currently_watching": movies.filter(watchlist=Watchlist.objects.get(list_name="currently_watching")),
"movies_on_hold": movies.filter(watchlist=Watchlist.objects.get(list_name="on_hold")),
"movies_plan_to_watch": movies.filter(watchlist=Watchlist.objects.get(list_name="plan_to_watch")),
"movies_completed": movies.filter(watchlist=Watchlist.objects.get(list_name="completed")),
})
page:-