Yuka and Shawn - Thanks very much for your help! Overriding
_clean_fields() does satisfy the requirements (including the dynamic
fields).
Rick
On Apr 14, 2:54 pm, Yuka Poppe wrote:
> Rick, as a followup;
>
> You also mentioned dynamicly adding fields in __init__, if you also
> want to return
On Thursday, April 14, 2011 7:09:57 PM UTC+1, ricksteu wrote:
>
> Shawn - The validation appears to actually takes place *before* the
> __init__ is called (during instantiation, not during initialization.)
> If you look at BaseForm, scroll past the __init__() method, and you'll
> see:
>
> d
Rick, as a followup;
You also mentioned dynamicly adding fields in __init__, if you also
want to return validation errors, you're better off overriding
_clean_fields() instead of full_clean(). Taking all requirements into
account (processing self.data before any fields are cleaned being the
most i
Hi Rick,
Ok, I did a quick skim over the BaseForm; Validation is called by the
method is_valid(), which inturn accesses the property self.errors --
And thus _get_errors() which calls self.full_clean()
full_clean() is responsible for calling the clean method on all
associated fields, and populatin
Hi Yuka - We do want to do the cleaning at the form level, basically
because we don't want to use a CharField subclass in all places on all
of our forms.You're right, there are two methods that can be
overridden: clean() and full_clean(). clean() occurs too late. I
think using full_clean() is
Shawn - The validation appears to actually takes place *before* the
__init__ is called (during instantiation, not during initialization.)
If you look at BaseForm, scroll past the __init__() method, and you'll
see:
def _get_errors(self):
"Returns an ErrorDict for the data provided for t
On Thu, Apr 14, 2011 at 5:32 AM, ricksteu wrote:
>
> Hello -
>
> I am looking for a straightforward way to alter posted form data prior
> to when the form's full_clean() method is called. Specifically, I
> need to strip whitespace from any string data (such as for
> CharFields), and this needs to
No data validation takes place any time during __init__, so it's not too late.
--
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
dja
Shawn - thanks for the reply, but the field cleaning occurs prior to
the super().__init__. It occurs in the form definition. So,
performing manipulation afterward would be too late.
The main problem with performing the manipulation after the field
cleaning is that I don't want a CharField with p
I believe you can customize your form's __init__ to handle this.
In the __init__, call the super() __init__ and then do your dynamic field jazz.
After that, you should be able to manipulate the data.
--
You received this message because you are subscribed to the Google Groups
"Django users" gr
Hello -
I am looking for a straightforward way to alter posted form data prior
to when the form's full_clean() method is called. Specifically, I
need to strip whitespace from any string data (such as for
CharFields), and this needs to be done prior to when the individual
fields' clean methods are
11 matches
Mail list logo