#16042: comments framework uses uncached content types
------------------------+----------------------------------
 Reporter:  cdestigter  |          Owner:  nobody
     Type:  Bug         |         Status:  new
Milestone:              |      Component:  contrib.comments
  Version:  1.3         |       Severity:  Normal
 Keywords:              |   Triage Stage:  Unreviewed
Has patch:  1           |  Easy pickings:  1
------------------------+----------------------------------
 We found our list views were doing too many database queries for content
 types, even with caching turned on.

 Turns out the comments framework is to blame, for using the uncached
 method ContentType.objects.get(...)

 This one-liner fixes it:

 {{{
 --- a/django/contrib/comments/templatetags/comments.py
 +++ b/django/contrib/comments/templatetags/comments.py
 @@ -49,7 +49,7 @@ class BaseCommentNode(template.Node):
      def lookup_content_type(token, tagname):
          try:
              app, model = token.split('.')
 -            return ContentType.objects.get(app_label=app, model=model)
 +            return ContentType.objects.get_by_natural_key(app, model)
          except ValueError:
              raise template.TemplateSyntaxError("Third argument in %r must
 be in the format 'app.model'" % tagname)
          except ContentType.DoesNotExist:
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/16042>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to