django: Use a text area in your form

It was just one of those days when I stumbled upon this little gotcha.

I was a bit baffled when my textarea field would not show up on the form.

class YourForm(forms.Form):
name = forms.CharField(maxlength = 20)

# Textarea done WRONG
#address = forms.Textarea()

# Textarea done right!
address = forms.CharField(widget = forms.widgets.Textarea())

A simple mistake and a little tricky to figure out because it fails silently.

Sparta
THIS IS SPARTA DJANGO!

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog