On 8/21/2010 7:23 PM, John Yeukhon Wong wrote:
> I don't think this code is working properly
>
That isn't a very helpful description. For better answers, please
describe what it is doing that it should not (or what it is not doing
that it should).
> from django import forms
> from django.contrib.auth.models import User
>
> def clean_email(self):
> email = self.cleaned_data['email']
> try:
> User.objects.get(email=email)
> except User.DoesNotExist:
> return email
> raise forms.ValidationError('This email address has been
> registered with an existing user.')
>
>
>
> How should I rewrite it properly? Thanks!!
>
Shouldn't clean_email() be a method of the form it's a part of? You
appear to have written it as a stand-alone function, so it probably
isn't being called at all.
regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
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.