from django import forms
from articles.models import Comment
class CommentForm(forms.ModelForm):
required_css_class = "required"
error_css_class = "error"
class Meta:
model = Comment
fields = ["username", "email", "content"]
def as_table(self):
"Return this form rendered as HTML
s -- excluding the ."
return self._html_output(
normal_row="
%(label)s | %(errors)s%(field)s%(help_text)s |
",
error_row=(
'%s |
'
' |
'
),
row_ender="",
help_text_html='
%s',
errors_on_separate_row=False,
)
def __init__(self, *args, **kwargs):
defaults = {
"label_suffix": "",
}
defaults.update(kwargs)
super().__init__(*args, **defaults)