27 lines
675 B
Python
27 lines
675 B
Python
from django import forms
|
|
|
|
from .utils import PersonSearch
|
|
|
|
|
|
class SearchForm(forms.Form):
|
|
limit = forms.DecimalField(
|
|
widget=forms.NumberInput(attrs={
|
|
'type': 'range',
|
|
'min': '0',
|
|
'max': '1',
|
|
'step': '0.02',
|
|
}),
|
|
required=False)
|
|
query = forms.CharField(
|
|
widget=forms.TextInput(attrs={
|
|
'autocomplete': 'off',
|
|
}))
|
|
|
|
def results(self):
|
|
query = self.cleaned_data['query']
|
|
try:
|
|
limit = float(self.cleaned_data.get('limit'))
|
|
except ValueError:
|
|
limit = 0.5
|
|
return iter(PersonSearch(limit=limit).search_query(query))
|