From 80348c4e03913ec45f67d00020e791fd9604fa6b Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 20 Aug 2020 09:48:11 +0200 Subject: [PATCH] Update form rendering --- articles/forms.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/articles/forms.py b/articles/forms.py index 9d8877b..9b58638 100644 --- a/articles/forms.py +++ b/articles/forms.py @@ -10,3 +10,24 @@ class CommentForm(forms.ModelForm): 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)