Auto trimming field value / Django forms

Июнь 7, 2010

I don’t know why this is not done by default, but..

from django import forms

class TrimmedCharField(forms.CharField):
	def clean(self, value):		
		return forms.CharField.clean(self, value.strip())

class Form1(forms.Form):
	f1 = TrimmedCharField(widget=forms.Textarea(attrs={'rows': 6}))
	f2= TrimmedCharField(widget=forms.Textarea(attrs={'rows': 6}))

posted in Python, Web by dmitko

1 Comment to "Auto trimming field value / Django forms"

  1. แอร์ ชลบุรี wrote:

    What’s up colleagues, how is everything,
    and what you would like to say on the topic of
    this paragraph, in my view its really remarkable in support
    of me.

Powered by Wordpress and MySQL. Theme by Shlomi Noach,