Re: ModelForms check if value has changed.

2008-04-08 Thread Petar
Found out why I got this error. I forgot to return a value for the validated field. Because this field was prohibited of being NULL, I got an error. I achieved what I wanted with the following code: if self.initial['email'] != self.cleaned_data['email']: try: user = U

Re: ModelForms check if value has changed.

2008-04-08 Thread Petar
> Within the ModelForm class just refer to self.initial['field_name']. Yeah, that's the one I needed! I got a strange error now though. When I try to check if the values have changed with: if self.initial['email'] != self.cleaned_data['email']: I get an exception: null value in column "email" v

Re: ModelForms check if value has changed.

2008-04-08 Thread Karen Tracey
On Tue, Apr 8, 2008 at 11:10 AM, Petar <[EMAIL PROTECTED]> wrote: > > Karen, > > this is a good solution if I wanted to do the validation inside the > view, where this value is available. > However, I want to raise a ValidationError inside the ModelForm class. > Therefore I need this value inside

Re: ModelForms check if value has changed.

2008-04-08 Thread Petar
Karen, this is a good solution if I wanted to do the validation inside the view, where this value is available. However, I want to raise a ValidationError inside the ModelForm class. Therefore I need this value inside this class. Is their a way to get a similar value in the newforms ModelForm cl

Re: ModelForms check if value has changed.

2008-04-07 Thread Thomas Guettler
Petar schrieb: > Dear someone, > > I have a ModelForm for my User (standard django) model. I want to > check if the email is unique so I created a clean_email method which > works fine. The only problem is that I only want to check the email > address when it's changed. > > Is their a way to get t

Re: ModelForms check if value has changed.

2008-04-07 Thread Karen Tracey
On Mon, Apr 7, 2008 at 9:37 AM, Petar <[EMAIL PROTECTED]> wrote: > > Hi Michael, > > your suggestion doesn't work for my situation. It isn't important if > the value has been filled in, but only if the value has changed from > the originally filled in value. Then you can checked the entered valu

Re: ModelForms check if value has changed.

2008-04-07 Thread Petar
Hi Michael, your suggestion doesn't work for my situation. It isn't important if the value has been filled in, but only if the value has changed from the originally filled in value. On 7 apr, 02:31, Michael <[EMAIL PROTECTED]> wrote: > Inside the clean method you have access to self.instance.pk,

Re: ModelForms check if value has changed.

2008-04-06 Thread Michael
Inside the clean method you have access to self.instance.pk, which returns true if there an instance (with an already established primary key) or false if there isn't already an instance. Hope that helps, Michael On Sun, Apr 6, 2008 at 5:44 PM, Petar <[EMAIL PROTECTED]> wrote: > > Dear someone,

ModelForms check if value has changed.

2008-04-06 Thread Petar
Dear someone, I have a ModelForm for my User (standard django) model. I want to check if the email is unique so I created a clean_email method which works fine. The only problem is that I only want to check the email address when it's changed. Is their a way to get the 'initial' value of the ema