Login

Using Textarea

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

  1. Treat empty value on DateRangeFilter as a filter for non filled dates by kmmbvnr 1 month, 1 week ago
  2. Django Settings Assignment Expressions aka Walrus Operator example by webology 2 months, 1 week ago
  3. codigo alto nivel by MrRocklion 4 months ago
  4. Load template from specific app by Krzysiek555 4 months, 3 weeks ago
  5. PostgreSQL JSON subqueries by dolamroth 4 months, 3 weeks ago

Comments

rubic (on February 27, 2007):

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})

#

Tobu (on October 15, 2007):

Thanks, I was rather confused that the naive

baz = forms.Textarea()

failed silently.

#

Please login first before commenting.