Grupo Django
unread,Apr 29, 2008, 4:28:14 AM4/29/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
HI,
I'm trying to make a custom Q-like object as Malcolm recommended me. I
have this code:
class FT:
def add_to_query( self, query, used_aliases ):
select={
'rank': "ts_rank_cd(tsv, query, 32)",
}
query.add_extra( select,None,('tsv @@
query',),None,None,None )
and I'm stuck with it. It's hard to understand the Query class
quickly.
I need a sql clause like this:
SELECT * FROM table, plainto_tsquery( %s ) as query WHERE tsv @@
query;
This is the simplest one.
I can't add 'plainto_tsquery( %s )' to extra tables since it renders
the content between double quotes.
Also, I try to use this class like the Q object:
items = Model.objects.filter( FT() )
FT should have a string argument to fill the content inside:
plainto_tsquery( %s )
Problems:
1.- This code fails. I get a TypeError, unpack non-sequence in line
914 of query.py:
arg, value = filter_expr
2.- I don't know how I can add: plainto_tsquery( %s ) to the sql
clause and make it work, it shouldn't be quoted.
3.-How can I pass the content to: plainto_tsquery( %s ) in order to
get: 'plainto_tsquery( 'words I want to search' )?
I'd appreciate your help.
Thank you.