- Author:
- joshua
- Posted:
- February 27, 2007
- Language:
- Python
- Version:
- Pre .96
- Score:
- 7 (after 11 ratings)
A very common field in forms is the <textarea>
, but newforms
has no such field. Instead, you must use a dummy field (such as newforms.CharField
) and use the newforms.widgets.Textarea()
widget to render a textarea.
1 2 3 4 5 6 7 8 9 | from django import newforms as forms
class myForm ( forms.Form ):
foo = forms.CharField ( maxlength=20 )
bar = forms.CharField ( maxlength-20 )
# Now here's the Textarea
baz = forms.CharField ( widget=forms.widgets.Textarea() )
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 8 months, 3 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 9 months ago
- Serializer factory with Django Rest Framework by julio 1 year, 3 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 4 months ago
- Help text hyperlinks by sa2812 1 year, 5 months ago
Comments
It's probably also worth mentioning that you may assign the rows and columns attributes in the widget:
widget=forms.widgets.Textarea(attrs={'rows':4, 'cols':60})
#
Thanks, I was rather confused that the naive
failed silently.
#
Please login first before commenting.