Closed adrysn closed 7 years ago
Hi! Can you post the changes to files to get work in django 1.10, please?
Hi, many thanks for the info, I've managed to get works with 1.10 with your suggestions
Just removing the third parameter context
from render_to_string
may raise following warning in Django>=1.10.
.../django/template/defaulttags.py:64: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.
This is because csrf_token
in context
object is not delivered to rendered comment form/list. So, original context
object should be given as the parameter of render_to_string
along with form
key.
I think render
method in RenderCommentFormNode
can be changed something like below.
context.push({"form": self.get_form(context)}
form_str = render_to_string(template_search_list, context)
context.pop()
Also, render
in RenderCommentListNode
may be changed to:
context.push({"comment_list": self.get_context_value_from_queryset(context, qs)})
liststr = render_to_string(template_search_list, context)
context.pop()
Dont remove the parameter, just change it to context.get('request')
I've fixed it slightly different in a243845088fac6f58de1a08d569837de97f17645
Using context.push()
did have other errors when using context.flatten()
as well.
I doubt there is a need to pass the request
as the parent context is already enriched with the context_processors
.
In Django 1.10, some parameters were removed from
render_to_string()
:So, the prototype looks like below.
But, the
render()
method inthreadedcomments_tags.py
'sRenderCommentFormNode
orRenderCommentListNode
class delivers context instance to therender_to_string()
as the third parameter, which should be a request object.Generally, it does not seem to cause errors, but sometimes it does. For my case,
AttributeError: 'RequestContext' object has no attribute 'META'
occurred when used with Python Social Auth (I'll attach full traceback at the end for reference).My problem was resolved by changing
context
tocontext.get('request')
inrender()
method or just removingcontext
from the method, but I'm not sure that is the correct fix.Traceback