Whoops, I think I hit the wrong reply option when I tried to post to
this just now as it doesn't seem to have gone to the group.

If what you're looking to do is to combine the results of both queries
into one then what you probably want to use are the django Q objects
to give something like this:

from django.db.models import Q
search_results = Activity.objects.filter(Q(firm__firms__icontains=q)|Q
(clients__client__icontains=q))

I hope this helps

-- G

P.S. If you want more info on Q objects, check out:
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

On Apr 16, 5:54 pm, nixon66 <nixon....@gmail.com> wrote:
> I have the view below and wonder if its possible to add other search
> results into the view or would I need to write seperate ones. Ideally,
> I'd like to have
>
> firm_search = Activity.objects.filter(firm__firms__icontains=q)
> client_search= Activity.objects.filter(clients__client__icontains=q)
>
> Would I just add these to the existing view? Confused? Any suggestion
> would be appreciated.
>
> def search_detail(request):
>     if 'q' in request.GET:
>         q = request.GET['q']
>         search_results = Activity.objects.filter
> (country__country__icontains=q)
>     else:
>         q = None
>         search_results = None
>     return render_to_response('country/search_detail.html',
>                 {'search_results': search_results, 'query': q})

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to