<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0">
<channel>
	<title>Comments for Subakva</title>
	
	<link>http://subakva.com</link>
	<description>Submerged in Esperanto</description>
	<lastBuildDate>Wed, 07 Dec 2011 13:56:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/subakva-comments" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="subakva-comments" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on Clone My Fields, Please by Wieslaw</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-5001</link>
		<dc:creator>Wieslaw</dc:creator>
		<pubDate>Wed, 07 Dec 2011 13:56:21 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-5001</guid>
		<description>Gabriel, here you have the correct line of code:

# Add the extra SELECT and WHERE options
        return self.extra(select={'relevance': match_expr},
                                where=[match_expr],
                                params=[query],
                                select_params=[query])

One parameter (i.e. variable 'query') has to be passed to additional select clause, another parameter (the same query variable in this case) - to where clause. For the first select_params is used, for the latter - params.</description>
		<content:encoded><![CDATA[<p>Gabriel, here you have the correct line of code:</p>
<p># Add the extra SELECT and WHERE options<br />
        return self.extra(select={&#8216;relevance&#8217;: match_expr},<br />
                                where=[match_expr],<br />
                                params=[query],<br />
                                select_params=[query])</p>
<p>One parameter (i.e. variable &#8216;query&#8217;) has to be passed to additional select clause, another parameter (the same query variable in this case) &#8211; to where clause. For the first select_params is used, for the latter &#8211; params.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by iff</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-3606</link>
		<dc:creator>iff</dc:creator>
		<pubDate>Mon, 04 Jul 2011 14:02:27 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-3606</guid>
		<description>Gabriel,
did you solve that problem?
I am having the same one
I am using Pyhon 2,6 and Django 1.3, it works fine on Django 1.0</description>
		<content:encoded><![CDATA[<p>Gabriel,<br />
did you solve that problem?<br />
I am having the same one<br />
I am using Pyhon 2,6 and Django 1.3, it works fine on Django 1.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by Jason Wadsworth</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-2470</link>
		<dc:creator>Jason Wadsworth</dc:creator>
		<pubDate>Wed, 16 Feb 2011 02:25:09 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-2470</guid>
		<description>Gabriel,

It's been a long time since I've looked at this code, and both Django and Python have moved on without me.

You might want to try posting your question on Stack Overflow:

http://stackoverflow.com/questions/ask</description>
		<content:encoded><![CDATA[<p>Gabriel,</p>
<p>It&#8217;s been a long time since I&#8217;ve looked at this code, and both Django and Python have moved on without me.</p>
<p>You might want to try posting your question on Stack Overflow:</p>
<p><a href="http://stackoverflow.com/questions/ask" rel="nofollow">http://stackoverflow.com/questions/ask</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by gabriel</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-2467</link>
		<dc:creator>gabriel</dc:creator>
		<pubDate>Tue, 15 Feb 2011 19:36:46 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-2467</guid>
		<description>Hi,
have you guys made this work?

I get a stopiteration exception at:
/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py in add_extra, line 1691

here is my code:
class SearchQuerySet(models.query.QuerySet):
     def __init__(self, model=None, fields=None, *args, **kwargs):
         super(SearchQuerySet, self).__init__(model, *args, **kwargs)
         self._search_fields = fields

     def search(self, query):
         meta = self.model._meta

         # Get the table name and column names from the model
         # in `table_name`.`column_name` style
         columns = [meta.get_field(name, many_to_many=False).column for name in self._search_fields]
         full_names = ["%s.%s" % (connection.ops.quote_name(meta.db_table), connection.ops.quote_name(column)) for column in columns] 

         # Create the MATCH...AGAINST expressions 
         fulltext_columns = ", ".join(full_names)
         match_expr = ("MATCH(%s) AGAINST (%%s)" % fulltext_columns)

         # Add the extra SELECT and WHERE options
         return self.extra(select={'relevance': match_expr}, where=[match_expr], params=[query, query]) 


class SearchManager(models.Manager):
     def __init__(self, fields, *args, **kwargs):
         super(SearchManager, self).__init__(*args, **kwargs)
         self._search_fields = fields

     def get_query_set(self):
         return SearchQuerySet(self.model, self._search_fields)

     def search(self, query):
         return self.get_query_set().search(query)</description>
		<content:encoded><![CDATA[<p>Hi,<br />
have you guys made this work?</p>
<p>I get a stopiteration exception at:<br />
/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py in add_extra, line 1691</p>
<p>here is my code:<br />
class SearchQuerySet(models.query.QuerySet):<br />
     def __init__(self, model=None, fields=None, *args, **kwargs):<br />
         super(SearchQuerySet, self).__init__(model, *args, **kwargs)<br />
         self._search_fields = fields</p>
<p>     def search(self, query):<br />
         meta = self.model._meta</p>
<p>         # Get the table name and column names from the model<br />
         # in `table_name`.`column_name` style<br />
         columns = [meta.get_field(name, many_to_many=False).column for name in self._search_fields]<br />
         full_names = ["%s.%s" % (connection.ops.quote_name(meta.db_table), connection.ops.quote_name(column)) for column in columns] </p>
<p>         # Create the MATCH&#8230;AGAINST expressions<br />
         fulltext_columns = &#8220;, &#8220;.join(full_names)<br />
         match_expr = (&#8220;MATCH(%s) AGAINST (%%s)&#8221; % fulltext_columns)</p>
<p>         # Add the extra SELECT and WHERE options<br />
         return self.extra(select={&#8216;relevance&#8217;: match_expr}, where=[match_expr], params=[query, query]) </p>
<p>class SearchManager(models.Manager):<br />
     def __init__(self, fields, *args, **kwargs):<br />
         super(SearchManager, self).__init__(*args, **kwargs)<br />
         self._search_fields = fields</p>
<p>     def get_query_set(self):<br />
         return SearchQuerySet(self.model, self._search_fields)</p>
<p>     def search(self, query):<br />
         return self.get_query_set().search(query)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by Andrew Pelt</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-1810</link>
		<dc:creator>Andrew Pelt</dc:creator>
		<pubDate>Sat, 06 Mar 2010 20:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-1810</guid>
		<description>Thanks for your article. I am new at python and this will be a big help.</description>
		<content:encoded><![CDATA[<p>Thanks for your article. I am new at python and this will be a big help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Only in Python… by Donnie</title>
		<link>http://subakva.com/2008/09/14/only-in-python/comment-page-1/#comment-914</link>
		<dc:creator>Donnie</dc:creator>
		<pubDate>Sat, 22 Aug 2009 23:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/?p=22#comment-914</guid>
		<description>You need more postings :-)  Btw, thank you for the interview.</description>
		<content:encoded><![CDATA[<p>You need more postings :-)  Btw, thank you for the interview.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by JR</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-203</link>
		<dc:creator>JR</dc:creator>
		<pubDate>Fri, 14 Nov 2008 00:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-203</guid>
		<description>This article and the accompanying comments were most helpful in converting MercuryTide's search to Django 1.0+ compatibility, thank you!

I ended up using MercuryTide's search as a starting point, but wrote the actual search aspect myself, because InnoDB doesn't support MySQL's fulltext search.</description>
		<content:encoded><![CDATA[<p>This article and the accompanying comments were most helpful in converting MercuryTide&#8217;s search to Django 1.0+ compatibility, thank you!</p>
<p>I ended up using MercuryTide&#8217;s search as a starting point, but wrote the actual search aspect myself, because InnoDB doesn&#8217;t support MySQL&#8217;s fulltext search.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by Yeago</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-24</link>
		<dc:creator>Yeago</dc:creator>
		<pubDate>Wed, 14 May 2008 16:54:09 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-24</guid>
		<description>I think that fixed one issue, Craig. 

Now I'm attempting to track down an odd bug whereby attempting to filter() a result-set results in [], regardless of match.</description>
		<content:encoded><![CDATA[<p>I think that fixed one issue, Craig. </p>
<p>Now I&#8217;m attempting to track down an odd bug whereby attempting to filter() a result-set results in [], regardless of match.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by Craig Ogg</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-21</link>
		<dc:creator>Craig Ogg</dc:creator>
		<pubDate>Tue, 29 Apr 2008 00:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-21</guid>
		<description>I haven't checked it to any real extent, but it looks like just bad subclassing form.  Adding *args and **kwargs in the usual way should make the problem disappear:

    def __init__(self, index_column, *args, **kwargs):
        super(SearchManager, self).__init__(*args, **kwargs)

Similarly for SearchQuerySet.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t checked it to any real extent, but it looks like just bad subclassing form.  Adding *args and **kwargs in the usual way should make the problem disappear:</p>
<p>    def __init__(self, index_column, *args, **kwargs):<br />
        super(SearchManager, self).__init__(*args, **kwargs)</p>
<p>Similarly for SearchQuerySet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Clone My Fields, Please by Yeago</title>
		<link>http://subakva.com/2008/02/26/clone-my-fields-please/comment-page-1/#comment-20</link>
		<dc:creator>Yeago</dc:creator>
		<pubDate>Mon, 28 Apr 2008 18:28:22 +0000</pubDate>
		<guid isPermaLink="false">http://subakva.com/2008/02/26/clone-my-fields-please/#comment-20</guid>
		<description>Don't suppose the SearchManager is choking upon the last svn update?

django/db/models/query.py 

line c = klass(model=self.model, query=self.query.clone())  

"__init__() got an unexpected keyword argument 'query'"

Digging around. Letcha know if I find something out.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t suppose the SearchManager is choking upon the last svn update?</p>
<p>django/db/models/query.py </p>
<p>line c = klass(model=self.model, query=self.query.clone())  </p>
<p>&#8220;__init__() got an unexpected keyword argument &#8216;query&#8217;&#8221;</p>
<p>Digging around. Letcha know if I find something out.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

