Add: basic search form
This commit is contained in:
parent
7716359e0b
commit
e11a69986b
1 changed files with 41 additions and 0 deletions
41
archivist/apps/sites/forms.py
Normal file
41
archivist/apps/sites/forms.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
from .models import Category
|
||||||
|
|
||||||
|
class SearchForm(forms.Form):
|
||||||
|
q = forms.CharField(
|
||||||
|
label='Search',
|
||||||
|
max_length=100,
|
||||||
|
required=True,
|
||||||
|
widget=forms.TextInput(
|
||||||
|
attrs={
|
||||||
|
'class': 'form-control',
|
||||||
|
'placeholder': 'Search'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
category = forms.ModelChoiceField(
|
||||||
|
label="Site",
|
||||||
|
queryset=Category.objects.all(),
|
||||||
|
empty_label="All Sites", # Sets the name of the null option
|
||||||
|
required=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
attrs={
|
||||||
|
'class': 'form-select',
|
||||||
|
'placeholder': 'All Sites'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
mature = forms.ChoiceField(
|
||||||
|
label="Filter by Mature",
|
||||||
|
choices=[('1', 'All'),('2', 'General'), ('3', 'Mature/Adult')],
|
||||||
|
initial='1',
|
||||||
|
required=False,
|
||||||
|
widget=forms.RadioSelect(
|
||||||
|
attrs={
|
||||||
|
'class': 'form-check-input',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue