Skip to content

Commit 7a54ec6

Browse files
committed
allow to make comments for non-abstract models by COMMENTS_FOR_CONCRETE_MODEL setting
1 parent 69b166a commit 7a54ec6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

django_comments/forms.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000)
1616
DEFAULT_COMMENTS_TIMEOUT = getattr(settings, 'COMMENTS_TIMEOUT', (2 * 60 * 60)) # 2h
17+
COMMENTS_FOR_CONCRETE_MODEL = getattr(settings, 'COMMENTS_FOR_CONCRETE_MODEL', True)
1718

1819

1920
class CommentSecurityForm(forms.Form):
@@ -138,7 +139,10 @@ def get_comment_create_data(self, site_id=None):
138139
method to add extra fields onto a custom comment model.
139140
"""
140141
return dict(
141-
content_type=ContentType.objects.get_for_model(self.target_object),
142+
content_type=ContentType.objects.get_for_model(
143+
self.target_object,
144+
for_concrete_model=COMMENTS_FOR_CONCRETE_MODEL,
145+
),
142146
object_pk=force_str(self.target_object._get_pk_val()),
143147
user_name=self.cleaned_data["name"],
144148
user_email=self.cleaned_data["email"],

0 commit comments

Comments
 (0)