Code

Ticket #9562: get_comment_app.diff

File get_comment_app.diff, 1.7 KB (added by oyvind, 5 years ago)

fix to make the comment templatetags use get_comment_app

Line 
1diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
2index 563a3ff..b5b02c8 100644
3--- a/django/contrib/comments/templatetags/comments.py
4+++ b/django/contrib/comments/templatetags/comments.py
5@@ -7,6 +7,8 @@ from django.utils.encoding import smart_unicode
6 
7 register = template.Library()
8 
9+comment_app = comments.get_comment_app()
10+
11 class BaseCommentNode(template.Node):
12     """
13     Base helper class (abstract) for handling the get_comment_* template tags.
14@@ -59,7 +61,7 @@ class BaseCommentNode(template.Node):
15     def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None):
16         if ctype is None and object_expr is None:
17             raise template.TemplateSyntaxError("Comment nodes must be given either a literal object or a ctype and object pk.")
18-        self.comment_model = comments.get_model()
19+        self.comment_model = comment_app.get_model()
20         self.as_varname = as_varname
21         self.ctype = ctype
22         self.object_pk_expr = object_pk_expr
23@@ -117,7 +119,7 @@ class CommentFormNode(BaseCommentNode):
24     def get_form(self, context):
25         ctype, object_pk = self.get_target_ctype_pk(context)
26         if object_pk:
27-            return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))
28+            return comment_app.get_form()(ctype.get_object_for_this_type(pk=object_pk))
29         else:
30             return None
31 
32@@ -243,7 +245,7 @@ def comment_form_target():
33 
34         <form action="{% comment_form_target %}" method="POST">
35     """
36-    return comments.get_form_target()
37+    return comment_app.get_form_target()
38 
39 register.tag(get_comment_count)
40 register.tag(get_comment_list)