Ticket #8630: 8630_r8782_alternative.diff

File 8630_r8782_alternative.diff, 1.7 KB (added by Carl Meyer, 9 years ago)

A patch to use get_comment_app in templatetags, so customization can work (but I actually think Thejaswi's patch is a better approach)

  • django/contrib/comments/templatetags/comments.py

     
    22from django.template.loader import render_to_string
    33from django.conf import settings
    44from django.contrib.contenttypes.models import ContentType
    5 from django.contrib import comments
     5from django.contrib.comments import get_comment_app
    66from django.utils.encoding import smart_unicode
    77
    88register = template.Library()
     
    5959    def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None):
    6060        if ctype is None and object_expr is None:
    6161            raise template.TemplateSyntaxError("Comment nodes must be given either a literal object or a ctype and object pk.")
    62         self.comment_model = comments.get_model()
     62        self.comment_model = get_comment_app().get_model()
    6363        self.as_varname = as_varname
    6464        self.ctype = ctype
    6565        self.object_pk_expr = object_pk_expr
     
    117117    def get_form(self, context):
    118118        ctype, object_pk = self.get_target_ctype_pk(context)
    119119        if object_pk:
    120             return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))
     120            return get_comment_app().get_form()(ctype.get_object_for_this_type(pk=object_pk))
    121121        else:
    122122            return None
    123123
     
    243243
    244244        <form action="{% comment_form_target %}" method="POST">
    245245    """
    246     return comments.get_form_target()
     246    return get_comment_app().get_form_target()
    247247
    248248register.tag(get_comment_count)
    249249register.tag(get_comment_list)
Back to Top