Created
June 14, 2014 14:19
-
-
Save Mark-Shine/6e1846169997097c0785 to your computer and use it in GitHub Desktop.
comments_for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.inclusion_tag("generic/includes/comments.html", takes_context=True) | |
def comments_for(context, obj): | |
""" | |
Provides a generic context variable name for the object that | |
comments are being rendered for. | |
""" | |
form = ThreadedCommentForm(context["request"], obj) | |
try: | |
context["posted_comment_form"] | |
except KeyError: | |
context["posted_comment_form"] = form | |
context["unposted_comment_form"] = form | |
context["comment_url"] = reverse("comment") | |
context["object_for_comments"] = obj | |
return context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment