Re: Newforms validations & request.user

2007-08-10 Thread Collin Grady

Makes the most sense to me :)


--~--~-~--~~~---~--~~
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: Newforms validations & request.user

2007-08-09 Thread Kai Kuehne

Hi,

On 8/9/07, Collin Grady <[EMAIL PROTECTED]> wrote:
>
> Add an __init__ function to your form that you can pass request to.
>
> def __init__(self, request=None, *args, **kwargs):
> self.request = request
> super(MyForm, self).__init__(*args, **kwargs)
>
> Something like that should work to add request to the form, and you
> can then use it in the clean_fieldname functions :)

Is this the recommended way to do this sort of thing?
I had created a view that returns a json/ajax/whatever response
and called it via javascript to get the old password.

Thanks :)
Kai

--~--~-~--~~~---~--~~
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: Newforms validations & request.user

2007-08-09 Thread Collin Grady

Add an __init__ function to your form that you can pass request to.

def __init__(self, request=None, *args, **kwargs):
self.request = request
super(MyForm, self).__init__(*args, **kwargs)

Something like that should work to add request to the form, and you
can then use it in the clean_fieldname functions :)


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Newforms validations & request.user

2007-08-09 Thread Michal

Hello,
I need to write form for re-setting user's password:

class SettingsForm(forms.Form):
 old_password = forms.CharField(max_length=200, required=False, 
widget=forms.PasswordInput(attrs=passw_dict, render_value=False), 
label=u'Actual password')
 password1 = forms.CharField(max_length=200, required=False, 
widget=forms.PasswordInput(attrs=passw_dict, render_value=False), 
label=u'New password')
 password2 = forms.CharField(max_length=200, required=False, 
widget=forms.PasswordInput(attrs=passw_dict, render_value=False), 
label=u'New password (again)')

I would like check old user password at form validation level. But is it 
possible? (I have no request object, so I don't know which user is 
actually logged in).

I could check it in view level too, but I would like to generate form 
error message (ie. invoke ValidationError exceprion outside of the form 
class). Is it possible please?


Regards
Michal


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---