diff --git a/comments/views.py b/comments/views.py index 4c5ce9c..c5bcf10 100644 --- a/comments/views.py +++ b/comments/views.py @@ -83,5 +83,8 @@ class CommentPostView(FormView): cache.delete('seo_processor') comment_cache_key = 'article_comments_{id}'.format(id=article_id) cache.delete(comment_cache_key) - + from django.core.cache.utils import make_template_fragment_key + username = self.request.user.username if self.request.user else '' + key = make_template_fragment_key('sidebar', [username]) + cache.delete(key) return HttpResponseRedirect("%s#div-comment-%d" % (article.get_absolute_url(), comment.pk)) diff --git a/templates/blog/article_index.html b/templates/blog/article_index.html index 2abebb9..83b6fdc 100644 --- a/templates/blog/article_index.html +++ b/templates/blog/article_index.html @@ -55,9 +55,7 @@ {% block sidebar %} - {% cache 36000 sidebar request.user.username %} - {% load_sidebar request.user %} - {% endcache %} + {% load_sidebar user %} {% endblock %}