Re: newforms: common constraints

2007-07-29 Thread james_027
hi, what will be the proper approach to do this? creating a custom fields or custom field validation? Thanks james On Jul 27, 10:53 pm, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> wrote: > On 7/27/07, james_027 <[EMAIL PROTECTED]> wrote: > > > but those min maxconstraintsare socommon? why not inclu

Re: newforms: common constraints

2007-07-27 Thread Tim Chase
>> but those min max constraints are so common? why not include >> it? > > Because "common" is different for any given user and/or site. > I think *I've* only written a single form with min/max > validation, FWIW. Designing a framework is hard; you've got to > search for things that are as close

Re: newforms: common constraints

2007-07-27 Thread Jacob Kaplan-Moss
On 7/27/07, james_027 <[EMAIL PROTECTED]> wrote: > but those min max constraints are so common? why not include it? Because "common" is different for any given user and/or site. I think *I've* only written a single form with min/max validation, FWIW. Designing a framework is hard; you've got to s

Re: newforms: common constraints

2007-07-26 Thread james_027
Thanks for the fast response Doug, but those min max constraints are so common? why not include it? james On Jul 27, 1:20 pm, Doug B <[EMAIL PROTECTED]> wrote: > Garg, hit enter too fast. > > Class MyForm(forms.Form): > username = forms.CharField(max_length=12) > def clean_username(self

Re: newforms: common constraints

2007-07-26 Thread Doug B
Garg, hit enter too fast. Class MyForm(forms.Form): username = forms.CharField(max_length=12) def clean_username(self): username = self.clean_data['username'] if username == 'bob': raise ValidationError("Bob is not allowed here") return username If so

Re: newforms: common constraints

2007-07-26 Thread Doug B
newforms does that, but it's up to you do take care of the details by either subclassing one of the existing fields like this snippet shows: http://www.djangosnippets.org/snippets/115/ Or by making a specially named method on the form definition like this: Class MyForm(forms.Form) username

newforms: common constraints

2007-07-26 Thread james_027
Hi all, I may not well understand the purpose of newforms, or perhaps it is still in a very early alpha stage ... I am looking to implement some common constraints like mininum or maximum letter of character field then values for numerical field., range for numerical or date field. Thanks james