forms.py
class SearchFilter(django_filters.FilterSet):
name = django_filters.CharFilter(lookup_expr='icontains')
language = django_filters.ModelMultipleChoiceFilter(queryset=Language_list.objects.all(),widget=forms.CheckboxSelectMultiple)
cast = django_filters.ModelMultipleChoiceFilter(queryset=Cast_list.objects.all(),widget=forms.CheckboxSelectMultiple)
class Meta:
model = Movies_list
fields=['name','language','cast']
views.py
def Search_list(request):
movies_list = Movies_list.objects.all()
movies_filter_complete = SearchFilter(request.GET, queryset=movies_list).qs
print(movies_filter_complete)
paginator = Paginator(movies_filter_complete, 2)
page = request.GET.get('page')
movies_filter = paginator.get_page(page)
print(movies_filter.has_next())
print(movies_filter)
return render(request, 'movies_list/search_details.html', {'filter': movies_filter,"movies_filter_complete":movies_filter_complete})
Работает без ошибок, просто хочуКак я могу напечатать пользовательский параметр фильтра на шаблон.
<form method="get">
<div class="form-group col-sm-8 col-md-6">
{{ filter.language.label_tag }}
<div>
{% for choice in filter.language %}
<label class="checkbox-inline">
{{ choice.tag }} {{ choice.choice_label }}
</label>
{% endfor %}
</div>
</div>
<button type="submit">Search</button>
</form>
Как я могу запустить эту форму.