I am working into someone else's solution, with this code in forms.py:
***************
class SearchForm(forms.Form):
area = forms.ModelChoiceField(label=_('Area'),
queryset=Area.objects.all(), required=False)
group = forms.ModelChoiceField(label=_('Group'),
queryset=Group.objects.all(), required=False)
q = forms.CharField(required=False, label=_('Query'),)
def filter_by(self):
# TODO search using more than one field
# TODO split query string and make seaprate search by words
filters = {}
if self.cleaned_data['group']:
filters['group'] = self.cleaned_data['group']
if self.cleaned_data['area']:
filters['area'] = self.cleaned_data['area']
filters['description__icontains'] = self.cleaned_data['q']
return filters
***************
I understand that 'filters' is a dictionary.
However, what I would like to do is have the final input ('q') be an
'or' search on two fields, ie:
filter(Q(description__icontains = self.cleaned_data['q']) | Q
(title__icontains = self.cleaned_data['q'])]
Not sure how to implement that in this dictionary style.
Thanks
-- Clive
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2525F534-DD0C-48E6-ABFC-D3D1FA29E09C%40indx.co.uk.