Mercurial > public > sg101
diff custom_search/forms.py @ 956:6cc9221d04a7
Issue #85: fix 500 error with custom search form.
Can't rely on exact being in cleaned_data if there is an error
with it.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 30 May 2015 17:41:11 -0500 |
parents | cf9918328c64 |
children | 2f36abf65a62 |
line wrap: on
line diff
--- a/custom_search/forms.py Tue May 19 21:08:45 2015 -0500 +++ b/custom_search/forms.py Sat May 30 17:41:11 2015 -0500 @@ -54,13 +54,17 @@ label='Search in', widget=forms.CheckboxSelectMultiple) def clean(self): + super(CustomModelSearchForm, self).clean() if not settings.SEARCH_QUEUE_ENABLED: raise forms.ValidationError("Our search function is offline for " "maintenance. Please try again later. " "We apologize for any inconvenience.") - if not (self.cleaned_data['q'] or self.cleaned_data['exact'] or - self.cleaned_data['exclude']): + q = self.cleaned_data.get('q') + exact = self.cleaned_data.get('exact') + exclude = self.cleaned_data.get('exclude') + + if not (q or exact or exclude): raise forms.ValidationError('Please supply some search terms') return self.cleaned_data