From 7a54ec6a97629f58b54b441eb21f58e72f4512a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= <petr.dlouhy@email.cz> Date: Tue, 19 Oct 2021 17:36:11 +0200 Subject: [PATCH] allow to make comments for non-abstract models by COMMENTS_FOR_CONCRETE_MODEL setting --- django_comments/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_comments/forms.py b/django_comments/forms.py index d9a9782..1048b4b 100644 --- a/django_comments/forms.py +++ b/django_comments/forms.py @@ -14,6 +14,7 @@ COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) DEFAULT_COMMENTS_TIMEOUT = getattr(settings, 'COMMENTS_TIMEOUT', (2 * 60 * 60)) # 2h +COMMENTS_FOR_CONCRETE_MODEL = getattr(settings, 'COMMENTS_FOR_CONCRETE_MODEL', True) class CommentSecurityForm(forms.Form): @@ -138,7 +139,10 @@ def get_comment_create_data(self, site_id=None): method to add extra fields onto a custom comment model. """ return dict( - content_type=ContentType.objects.get_for_model(self.target_object), + content_type=ContentType.objects.get_for_model( + self.target_object, + for_concrete_model=COMMENTS_FOR_CONCRETE_MODEL, + ), object_pk=force_str(self.target_object._get_pk_val()), user_name=self.cleaned_data["name"], user_email=self.cleaned_data["email"],