<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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/"
		>
<channel>
	<title>Comments on: Named Scopes for Django</title>
	<atom:link href="http://furrybrains.com/2009/06/22/named-scopes-for-django/feed/" rel="self" type="application/rss+xml" />
	<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/</link>
	<description>The Furry Brains blog tackles a wide range of issues related to web development and design.</description>
	<lastBuildDate>Wed, 18 Aug 2010 12:46:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Empty</title>
		<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/comment-page-1/#comment-22</link>
		<dc:creator>Empty</dc:creator>
		<pubDate>Sat, 12 Sep 2009 15:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://furrybrains.com/?p=155#comment-22</guid>
		<description>Nice work.  While working on Django-SQLAlchemy I also wondered why QuerySet is separate from the Manager and I believe at that time I figured out the rationale for that, but it escapes me at the moment.  I like having a single manager with all the business logic scoping rules in one place.</description>
		<content:encoded><![CDATA[<p>Nice work.  While working on Django-SQLAlchemy I also wondered why QuerySet is separate from the Manager and I believe at that time I figured out the rationale for that, but it escapes me at the moment.  I like having a single manager with all the business logic scoping rules in one place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gaynor</title>
		<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/comment-page-1/#comment-18</link>
		<dc:creator>Alex Gaynor</dc:creator>
		<pubDate>Tue, 23 Jun 2009 17:28:41 +0000</pubDate>
		<guid isPermaLink="false">http://furrybrains.com/?p=155#comment-18</guid>
		<description>Yep, they can be nested since the QuerySet clones it&#039;s current class when you chain methods.  I don&#039;t believe mine will work with propeties like yours does though.</description>
		<content:encoded><![CDATA[<p>Yep, they can be nested since the QuerySet clones it&#8217;s current class when you chain methods.  I don&#8217;t believe mine will work with propeties like yours does though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Dalton</title>
		<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/comment-page-1/#comment-17</link>
		<dc:creator>Jim Dalton</dc:creator>
		<pubDate>Tue, 23 Jun 2009 14:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://furrybrains.com/?p=155#comment-17</guid>
		<description>@Alex -Thanks for sharing that; I like what you&#039;ve done there. I did not understand your last paragraph though (in your blog post). In what sense are you repeating yourself? It seems like your solution allows you to define your manager methods in a custom manager class and then they become part of the Queryset. Where do you have to define them again?

Also, can you nest manager methods using your approach?

@Carl - Yeah, the deferring aspect of this is really non-essential. For me, my only real goals were to be able to chain and nest custom manager methods. I actually agree with you; Alex&#039;s method appears to be simpler and if it works cleanly it&#039;s probably better than mine. (My solution, by the way, is a lot &quot;simpler&quot; than it looks. Most of the code amounts to an elegant hack to facilitate it via the @scope decorator.)

And by the way, I agree with you about Django. My instinct is that custom manager methods should be chainable just like the default QuerySet methods. Not only is this not yet a feature of Django, but I couldn&#039;t even find much chatter about it, so I&#039;m not holding my breath.

Well, I&#039;ll have to give Alex&#039;s idea a try to see if it does the trick for me. Thanks to both of you for the feedback.</description>
		<content:encoded><![CDATA[<p>@Alex -Thanks for sharing that; I like what you&#8217;ve done there. I did not understand your last paragraph though (in your blog post). In what sense are you repeating yourself? It seems like your solution allows you to define your manager methods in a custom manager class and then they become part of the Queryset. Where do you have to define them again?</p>
<p>Also, can you nest manager methods using your approach?</p>
<p>@Carl &#8211; Yeah, the deferring aspect of this is really non-essential. For me, my only real goals were to be able to chain and nest custom manager methods. I actually agree with you; Alex&#8217;s method appears to be simpler and if it works cleanly it&#8217;s probably better than mine. (My solution, by the way, is a lot &#8220;simpler&#8221; than it looks. Most of the code amounts to an elegant hack to facilitate it via the @scope decorator.)</p>
<p>And by the way, I agree with you about Django. My instinct is that custom manager methods should be chainable just like the default QuerySet methods. Not only is this not yet a feature of Django, but I couldn&#8217;t even find much chatter about it, so I&#8217;m not holding my breath.</p>
<p>Well, I&#8217;ll have to give Alex&#8217;s idea a try to see if it does the trick for me. Thanks to both of you for the feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl Meyer</title>
		<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/comment-page-1/#comment-16</link>
		<dc:creator>Carl Meyer</dc:creator>
		<pubDate>Tue, 23 Jun 2009 14:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://furrybrains.com/?p=155#comment-16</guid>
		<description>Interesting work, but seems like it&#039;s partially based on a misunderstanding of how Django querysets work.  Django querysets are always lazy (nothing is executed until the final queryset is sliced or iterated), so all the work to &quot;defer&quot; calls is pointless.  In that sense this gives you no advantage over plain manager methods.

It does give you the ability to chain manager methods, which is nice.  But as Alex said, the simpler solution to that is to move the methods onto a custom QuerySet class which your custom Manager returns, and then also proxy the methods onto your Manager (or use his &quot;magic manager&quot; to keep things DRY). Though I can&#039;t help but wonder if the fact that you have to do this at all is a design flaw in Django; seems to me like there isn&#039;t much good reason for Manager and QuerySet to be separate classes in the first place.  I wonder what it would look like to unite them...</description>
		<content:encoded><![CDATA[<p>Interesting work, but seems like it&#8217;s partially based on a misunderstanding of how Django querysets work.  Django querysets are always lazy (nothing is executed until the final queryset is sliced or iterated), so all the work to &#8220;defer&#8221; calls is pointless.  In that sense this gives you no advantage over plain manager methods.</p>
<p>It does give you the ability to chain manager methods, which is nice.  But as Alex said, the simpler solution to that is to move the methods onto a custom QuerySet class which your custom Manager returns, and then also proxy the methods onto your Manager (or use his &#8220;magic manager&#8221; to keep things DRY). Though I can&#8217;t help but wonder if the fact that you have to do this at all is a design flaw in Django; seems to me like there isn&#8217;t much good reason for Manager and QuerySet to be separate classes in the first place.  I wonder what it would look like to unite them&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gaynor</title>
		<link>http://furrybrains.com/2009/06/22/named-scopes-for-django/comment-page-1/#comment-15</link>
		<dc:creator>Alex Gaynor</dc:creator>
		<pubDate>Mon, 22 Jun 2009 21:02:11 +0000</pubDate>
		<guid isPermaLink="false">http://furrybrains.com/?p=155#comment-15</guid>
		<description>This is ultimately very similar to something I wrote about a few months ago: http://lazypython.blogspot.com/2009/01/building-magic-manager.html .  In the end I find the best solution is just to subclass QuerySet and proxy the methods onto my Manager by hand however.</description>
		<content:encoded><![CDATA[<p>This is ultimately very similar to something I wrote about a few months ago: <a href="http://lazypython.blogspot.com/2009/01/building-magic-manager.html" rel="nofollow">http://lazypython.blogspot.com/2009/01/building-magic-manager.html</a> .  In the end I find the best solution is just to subclass QuerySet and proxy the methods onto my Manager by hand however.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
