Re: Partial Validation in newforms
On Nov 28, 2007 7:44 AM, PlanarPlatypus <[EMAIL PROTECTED]> wrote: > > On Nov 28, 2:10 am, Thejaswi Puthraya <[EMAIL PROTECTED]> > wrote: > > On Nov 27, 8:32 pm, PlanarPlatypus <[EMAIL PROTECTED]> > > wrote: > > > > > Does anyone know of a clean way to do partial validation in djangos > > > newforms. I am basically after a cleaner way to do something like the > > > code below. > > > > A clarification...what do you mean by partial validation? Does it mean > > that you clean each field before cleaning the form. Looks like you > > have got the fundae wrong. Check out James Bennett's blog > > onhttp://www.b-list.org/weblog/2007/nov/22/newforms/for how newforms > > work exactly. > > What I mean is "is there a clean way to check if any of the fields are > valid and if so give me the data from those fields". As you can see, > at the moment I have to check each field manually for validity. > > The basic workflow involves keeping drafts of the users build even if > they didn't give all the information (Saving the valid values to the > database). Wouldn't it be easier just to have required=False for every field in that case? Presumably you already have the corresponding models fields as being null/blank? You could make this configurable when constructing the form, setting it up with fields required when you're doing final validation, so you can use the same form for both purposes: def __init__(draft=False, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) if draft: for field in self.fields: field.required = False Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Partial Validation in newforms
On Nov 28, 2:10 am, Thejaswi Puthraya <[EMAIL PROTECTED]> wrote: > On Nov 27, 8:32 pm, PlanarPlatypus <[EMAIL PROTECTED]> > wrote: > > > Does anyone know of a clean way to do partial validation in djangos > > newforms. I am basically after a cleaner way to do something like the > > code below. > > A clarification...what do you mean by partial validation? Does it mean > that you clean each field before cleaning the form. Looks like you > have got the fundae wrong. Check out James Bennett's blog > onhttp://www.b-list.org/weblog/2007/nov/22/newforms/for how newforms > work exactly. What I mean is "is there a clean way to check if any of the fields are valid and if so give me the data from those fields". As you can see, at the moment I have to check each field manually for validity. The basic workflow involves keeping drafts of the users build even if they didn't give all the information (Saving the valid values to the database). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Partial Validation in newforms
On Nov 27, 8:32 pm, PlanarPlatypus <[EMAIL PROTECTED]> wrote: > Does anyone know of a clean way to do partial validation in djangos > newforms. I am basically after a cleaner way to do something like the > code below. A clarification...what do you mean by partial validation? Does it mean that you clean each field before cleaning the form. Looks like you have got the fundae wrong. Check out James Bennett's blog on http://www.b-list.org/weblog/2007/nov/22/newforms/ for how newforms work exactly. Cheers Thejaswi Puthraya http://thejaswi.info/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---