diff --git a/django_comments/forms.py b/django_comments/forms.py index 814b5f9..cd94f27 100644 --- a/django_comments/forms.py +++ b/django_comments/forms.py @@ -143,7 +143,6 @@ def get_comment_create_data(self): user_url=self.cleaned_data["url"], comment=self.cleaned_data["comment"], submit_date=timezone.now(), - site_id=settings.SITE_ID, is_public=True, is_removed=False, ) diff --git a/django_comments/templatetags/comments.py b/django_comments/templatetags/comments.py index 62aeef0..77fbb71 100644 --- a/django_comments/templatetags/comments.py +++ b/django_comments/templatetags/comments.py @@ -78,9 +78,13 @@ def get_queryset(self, context): qs = self.comment_model.objects.filter( content_type=ctype, - object_pk=smart_text(object_pk), - site__pk=settings.SITE_ID, - ) + object_pk=smart_text(object_pk)) + try: + site_id = settings.SITE_ID + except AttributeError: + pass + else: + qs = qs.filter(site__pk=site_id) # The is_public and is_removed fields are implementation details of the # built-in comment model's spam filtering system, so they might not diff --git a/django_comments/views/comments.py b/django_comments/views/comments.py index c03c3c3..1886bd7 100644 --- a/django_comments/views/comments.py +++ b/django_comments/views/comments.py @@ -3,8 +3,8 @@ from django import http from django.apps import apps from django.conf import settings +from django.contrib.sites.models import Site from django.core.exceptions import ObjectDoesNotExist, ValidationError -from django.db import models from django.shortcuts import render from django.template.loader import render_to_string from django.utils.html import escape @@ -105,6 +105,7 @@ def post_comment(request, next=None, using=None): comment.ip_address = request.META.get("REMOTE_ADDR", None) if request.user.is_authenticated(): comment.user = request.user + comment.site_id = Site.objects.get_current(request).pk # Signal that the comment is about to be saved responses = signals.comment_will_be_posted.send(