search_string = req.REQUEST.get("search", "")

    query = Model1.objects

    if search_string == "":
        query = query.all()
    else:
        query = query.filter(
           Q(text_field__icontains=search_string) |
           Q(fek_field__text_field__icontains=search_string))

the query variable will return the search results.

On 5/22/10, urukay <radovan.be...@gmail.com> wrote:
>
> No that's not what i want..i want search model over another model.
>
>
>
> esatterwh...@wi.rr.com wrote:
>>
>> You probably want to use the indexer argument. It allows you to
>> specify which indexes you want sphinx to search over. Of course you
>> have to tell sphinx which indexes ( models ) you want it to search in.
>>
>> http://www.sphinxsearch.com/docs/current.html#ref-indexer
>>
>> On May 21, 8:47 am, urukay <radovan.be...@gmail.com> wrote:
>>> Well, still trying to solve it...maybe i found the right way to do it,
>>> but
>>> it's still in progress. If anything shows up, i'll keep you updated.
>>> Hopefully this during few days i'll solve it.
>>>
>>> Radovan
>>>
>>>
>>>
>>>
>>>
>>> yafeng wu wrote:
>>>
>>> > Hi,
>>>
>>> > I got the same problem when building my website. Have you solved it?
>>> > Please let me know.
>>>
>>> > Thanks,
>>>
>>> > On Apr 13, 4:04 am, urukay <radovan.be...@gmail.com> wrote:
>>> >> Hi,
>>>
>>> >> I'm trying to create full text search on model, everything goes fine
>>> >> when
>>> >> searching TextFields but I have a problem with ForeignKey field.
>>>
>>> >> How can i do that? Can anyone point me to the right direction?
>>>
>>> >> Thanks
>>>
>>> >> Model example:
>>>
>>> >> class Model1(models.Model):
>>>
>>> >>      text_field =models.TextField(max_length=250)
>>> >>      fek_field = models.ForeignKey('Model2')
>>>
>>> >> class Model2(models.Model):
>>> >>      text_field = models.TextField(max_length=250)
>>>
>>> >> --
>>> >> View this message in
>>> >>
>>> context:http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28219147p282...
>>> >> Sent from the django-users mailing list archive at Nabble.com.
>>>
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django-us...@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.
>>>
>>> --
>>> View this message in
>>> context:http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28228784p286...
>>> Sent from the django-users mailing list archive at Nabble.com.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group
>>> athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>>
>
> --
> View this message in context:
> http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28228784p28644474.html
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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