djangoで掲示板サイトの検索機能を作ろうとしてます。
base.htmlで入力を受け付け、views.pyで複数の入力を受け取ろうとしていますが、うまく受け取れません。
やったこと
querysetがしっかり動くことは確認しました
個人的にbase.htmlの記述が間違っているのではないかと思っています。
原因がわかる方がいましたら教えていただけると幸いです。
現状のコード
base.html
<section class="main__function">
<!-- select -->
<section class="select">
<div class="select__inner">
<form method="GET" action="{% url 'threads:searchtag' %}">
<h2 class="select__title select__game">Select me</h2>
<div class="select__radio">
<div class="form-check select__check">
<img src='' alt="">
<input class="form-check-input select__game__input" type="radio" name="selectme" id="Selection 1">
<label class="form-check-label select__game__label" for="Selection 1">
Select 1
</label>
</div>
<div class="form-check select__check">
<img src='' alt="">
<input class="form-check-input select__game__input" type="radio" name="selectme" id="Selection 2">
<label class="form-check-label select__game__label" for="Selection 2">
Select 2
</label>
</div>
<div class="form-check select__check">
<img src='' alt="">
<input class="form-check-input select__game__input" type="radio" name="selectme" id="Selection 3">
<label class="form-check-label select__game__label" for="Selection 3">
Select 3
</label>
</div>
</div>
<h2 class="select__title">Select tag</h2>
<div class="select__option">
<div class="select__wrapper">
<i class="fa-solid fa-chevron-down"></i>
<select name="tag1" class="form-select select__select" aria-label="Default select example">
<option value="" selected>Select first tag...</option>
<option value="1">Game content</option>
<option value="2">Competition</option>
</select>
</div>
<div class="select__wrapper">
<i class="fa-solid fa-chevron-down"></i>
<select name="tag2" class="form-select select__select" aria-label="Default select example">
<option value="" selected>Select Second tag...</option>
<option value="1">Game content</option>
<option value="2">Competition</option>
</select>
</div>
</div>
<input type="submit" class="select__btn btn">
</form>
</div>
</section>
views.py
class SearchTagView(generic.ListView):
template_name = 'article.html'
model = Article
paginate_by = 10
def get_queryset(self):
query = Q()
queryset = Article.objects.all()
query = self.request.GET
q1=query.get('selectgame',None)
q2=query.get('tag1',None)
q3=query.get('tag2',None)
queryset = queryset.filter(
Q(game_title__icontains=q1),Q(tag1=q2) , Q(tag2=q3))
return queryset