I have a model named UserInfo with the following fields: id, name, number
I want to create a custom search page. This will have the following elements: Search Box, Search Button Text field to match NAME Text field to match NUMBER
How it should work: Let's say I input 'John' as the name and '1234' as the number in the respective text boxes and click search. The result should show me the entries which has 'John' as the name and '1234' as the number.
The query is something like the following I guess: UserInfo.objects.filter(name='John').filter(number='1234')
I have made this kind of queries in PHP before, but that doesn't work in Django. I want to know what code can I use to associate multiple FILTERS in a query so that if there is data input in both name and number text boxes I get a query like the above but if I search for name only then the query becomes: UserInfo.object.filter(name='John') instead of
UserInfo.object.filter(name='John').filter(number='')
There should be an easy solution for this, I dunno. Very confused. :-/