Skip to content

Commit

Permalink
allow to make comments for non-abstract models by COMMENTS_FOR_CONCRE…
Browse files Browse the repository at this point in the history
…TE_MODEL setting
  • Loading branch information
PetrDlouhy committed Oct 19, 2021
1 parent 69b166a commit 7a54ec6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion django_comments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"],
Expand Down

0 comments on commit 7a54ec6

Please sign in to comment.