Skip to content

Commit 82856c6

Browse files
committed
make sure the "request" is included in the ajax view call
1 parent cea1fff commit 82856c6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

fluent_comments/templatetags/fluent_comments_tags.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def get_template_name(self, *tag_args, **tag_kwargs):
145145
return get_comment_template_name(comment=tag_args[0])
146146

147147
def get_context_data(self, parent_context, *tag_args, **tag_kwargs):
148-
return get_comment_context_data(comment=tag_args[0])
148+
context = get_comment_context_data(comment=tag_args[0])
149+
context['request'] = parent_context.get('request')
150+
return context
149151

150152

151153
@register.tag

fluent_comments/views.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import django
12
from django.core.exceptions import ObjectDoesNotExist, ValidationError
23
from django.http import HttpResponse, HttpResponseBadRequest
34
from django.template.loader import render_to_string
@@ -130,8 +131,13 @@ def _ajax_result(request, form, action, comment=None, object_id=None):
130131
if comment is not None:
131132
# Render the comment, like {% render_comment comment %} does
132133
context = get_comment_context_data(comment, action)
134+
context['request'] = request
133135
template_name = get_comment_template_name(comment)
134-
comment_html = render_to_string(template_name, context)
136+
137+
if django.VERSION >= (1, 8):
138+
comment_html = render_to_string(template_name, context, request=request)
139+
else:
140+
comment_html = render_to_string(template_name, context)
135141

136142
json_return.update({
137143
'html': comment_html,

0 commit comments

Comments
 (0)