Update form rendering
This commit is contained in:
parent
b96843a231
commit
80348c4e03
1 changed files with 21 additions and 0 deletions
|
@ -10,3 +10,24 @@ class CommentForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Comment
|
model = Comment
|
||||||
fields = ["username", "email", "content"]
|
fields = ["username", "email", "content"]
|
||||||
|
|
||||||
|
def as_table(self):
|
||||||
|
"Return this form rendered as HTML <tr>s -- excluding the <table></table>."
|
||||||
|
return self._html_output(
|
||||||
|
normal_row="<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>",
|
||||||
|
error_row=(
|
||||||
|
'<tr class="error nonfield"><td colspan="2">%s</td></tr>'
|
||||||
|
'<tr class="spacer"><td colspan="2"></td></tr>'
|
||||||
|
),
|
||||||
|
row_ender="</td></tr>",
|
||||||
|
help_text_html='<br><span class="helptext">%s</span>',
|
||||||
|
errors_on_separate_row=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
defaults = {
|
||||||
|
"label_suffix": "",
|
||||||
|
}
|
||||||
|
defaults.update(kwargs)
|
||||||
|
|
||||||
|
super().__init__(*args, **defaults)
|
||||||
|
|
Reference in a new issue