Scaffold containerized Django/Wagtail app with core features
This commit is contained in:
19
apps/comments/forms.py
Normal file
19
apps/comments/forms.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django import forms
|
||||
|
||||
from apps.comments.models import Comment
|
||||
|
||||
|
||||
class CommentForm(forms.ModelForm):
|
||||
honeypot = forms.CharField(required=False)
|
||||
article_id = forms.IntegerField(widget=forms.HiddenInput)
|
||||
parent_id = forms.IntegerField(required=False, widget=forms.HiddenInput)
|
||||
|
||||
class Meta:
|
||||
model = Comment
|
||||
fields = ["author_name", "author_email", "body"]
|
||||
|
||||
def clean_body(self):
|
||||
body = self.cleaned_data["body"]
|
||||
if not body.strip():
|
||||
raise forms.ValidationError("Comment body is required.")
|
||||
return body
|
||||
Reference in New Issue
Block a user