1

我想我已经把范围缩小到了 Disqus 评论。我正在尝试计算博客文章的点击次数。我正在使用 Mezzanine 和内置博客应用程序,因为该应用程序支持 Disqus 评论。但是,当我启用 Disqus 评论时,django_hitcount 应用程序停止工作,即使 2 不应该真正相关。http 403 error当 django_hitcount 模块尝试POST使用 Javascript 将数据发送到它的 hitcounter 时,我得到了一个。

当我以管理员身份登录时,它可以工作,但我希望它可以与匿名访问者一起工作。所以它以某种方式与夹层权限和夹层评论设置有关。再次总结一下,它总是在启用 django 注释的情况下工作。除非以管理员身份登录,否则不适用于启用 Disqus 评论和禁用 django 评论。

我不想对评论做任何事情。它与 django_hitcount 模块在内部的工作方式有关。启用 Disqus 评论时好像不喜欢,对应 django 评论禁用,而你没有登录。

我想我已经使用 python pbg 调试器将其缩小到 hitcount_tags.py 中的以下行。 https://github.com/thornomad/django-hitcount/blob/master/hitcount/templatetags/hitcount_tags.py

ctype, object_pk = get_target_ctype_pk(context, self.object_expr)

这就是它使用的功能。

def get_target_ctype_pk(context, object_expr):
# I don't really understand how this is working, but I took it from the
# comment app in django.contrib and the removed it from the Node.

try:
    obj = object_expr.resolve(context)
except template.VariableDoesNotExist:
    return None, None
return ContentType.objects.get_for_model(obj), obj.pk

我不知道这是在做什么,希望有人能解释一下。 https://github.com/django/django/blob/master/django/contrib/comments/templatetags/comments.py

也可能为什么在启用 Mezzanine disqus 评论并且用户未登录时它会失败。

4

0 回答 0