Author: brosner
Date: Sat Oct 11 09:29:00 2008
New Revision: 1031
Modified:
trunk/apps/local_apps/zwitschern/templatetags/zwitschern.py
Log:
Added a select_related call to tweet listing to prevent N+1 queries on its
dataset.
Modified: trunk/apps/local_apps/zwitschern/templatetags/zwitschern.py
==============================================================================
--- trunk/apps/local_apps/zwitschern/templatetags/zwitschern.py (original)
+++ trunk/apps/local_apps/zwitschern/templatetags/zwitschern.py Sat Oct 11
09:29:00 2008
@@ -1,10 +1,16 @@
+
from django import template
+
register = template.Library()
@register.inclusion_tag('zwitschern/listing.html', takes_context=True)
def tweet_listing(context, tweets, prefix_sender, are_mine):
request = context.get('request', None)
- sc = {'tweets': tweets, 'prefix_sender': prefix_sender, 'are_mine':
are_mine}
+ sc = {
+ 'tweets': tweets.select_related(depth=1),
+ 'prefix_sender': prefix_sender,
+ 'are_mine': are_mine
+ }
if request is not None:
sc['request'] = request
return sc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---