Редактирование стиля фильтра Django
Я пытаюсь отредактировать следующий фильтр, чтобы сделать несколько вещей:
- Remove the field name from outside of the TextInput and use that as the Hint Text
- Keep all filters on a single line within a flex container (currently, the week filter is the entire page-wide and the submit button is on a third line)
- Make WEEK_CHOICES based on unique values within the field Week, rather than hardcoded to weeks 1-3 (e.g. once an entry with Week 4 is submitted, auto-include this in the filter)
Любая помощь будет принята с благодарностью.
filters.py
class PickFilter(django_filters.FilterSet):
WEEK_CHOICES = (
('Week 1', 'Week 1'),
('Week 2', 'Week 2'),
('Week 3', 'Week 3'),
)
name = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control text-white text-center'}))
week = django_filters.ChoiceFilter(choices=WEEK_CHOICES, widget=forms.Select(attrs={'class': 'form-control form-control-sm'}))
class Meta:
model = Pick
fields = ['name','week',]
pick_list.html
{% extends 'base.html' %}
{% load cms_tags %}
{% block title %} {{ title }} · {{ block.super }} {% endblock title %}
{% block content %}
<div style="font-size:24px">
{{ title }}
</div>
<div style="font-size:14px; margin-bottom:15px">
Click on the arrows on the right of each contestant and drag them up or down to reorder them based on how far you think they are going to go.
</div>
<form method="get">
{{ myFilter.form }}
<button class="btn btn-primary" type="submit">Search</button>
</form>
<ul>