By default _form.as._p spits out:
Pretty much what Brian describes above. I would write a new method for your form like as_myp. I made this for myself. I took as_table method and made as_plain to remove the tr/th markups. Ex.
class MyForm(forms.Form):
my_field1 = forms.CharField(...)
my_field2 = forms.WhateverField(...)
def as_myp(self):
"Returns this form rendered as HTML s."
return self._html_output(
normal_row = '
%(label)s
%(field)s%(help_text)s
',
error_row = '%s',
row_ender = '',
help_text_html = ' %s',
errors_on_separate_row = True)
def as_plain(self):
"Returns 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)
It just seemed easier to do that than write a template file and handle form field rendering with errors, tags, visible/hidden, etc.
- 热议问题