# HG changeset patch # User Brian Neal # Date 1433025671 18000 # Node ID 6cc9221d04a7eac4dc73859753599d8e2daf987d # Parent 8647a669edb443a2a8a12c8dfd5dba86809a7758 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. diff -r 8647a669edb4 -r 6cc9221d04a7 custom_search/forms.py --- 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