Reputation: 4434
Have a basic question about how to show to tags in one within Django framework. I would like my HTML table looks like:
<table>
<tr>
<td>Cell1</td>
<td>Cell2</td>
</tr>
</table>
from django import forms
class PFAMInp(forms.Form):
Cell1 = forms.CharField(widget=forms.Textarea (attrs={'cols': 20, 'rows': 2}))
Cell2 = forms.FloatField(required=True)
Later I am using Python to convert this Django form into HTML on GAE.
class PFAMInputPage(webapp.RequestHandler):
def get(self):
html = html + str(PFAMdb.PFAMInp())
self.response.out.write(html)
app = webapp.WSGIApplication([('/.*', PFAMInputPage)], debug=True)
def main():
run_wsgi_app(app)
if __name__ == '__main__':
main()
My question is: Is there a way to customize this django template to make it show two in one row, rather than showing two tags? Thanks for any suggestions.
Upvotes: 1
Views: 205
Reputation: 3046
You have the option of calling the form using Form.as_p()
or Form.as_ul()
which will print the form as a series of <p>
tags or <li>
tags, respectively.
The full API specification is here.
Here's an example of how this might work:
from django import forms
class PFAMInp(forms.Form):
Cell1 = forms.CharField(widget=forms.Textarea (attrs={'cols': 20, 'rows': 2}))
Cell2 = forms.FloatField(required=True)
pfami_form = PFAMInp().as_p()
Upvotes: 1