Hello,
I've done it !!! yooohooo.

But I think this is not the best way because it can be processor time
consuming if I've a lots of suscribers (Wich is not the case now).

Here is the code in forms.py:

class Step1Form(forms.Form):
    email_adresse = forms.EmailField(max_length=255)
    telephone = forms.CharField(max_length=14)

    def clean(self):
        """
       Test if email_adresse is already in the database

        """

        if 'email_adresse' in self.cleaned_data :
            l = []
            for p in Customer.objects.all():
                l.append(p.email_adresse)
            if self.cleaned_data['email_adresse'] in l:
                raise forms.ValidationError(u'Email already exist')
        return self.cleaned_data

It works ....


I'll try with another method function:

p=Customer.objects.all()
try:
    p.objects.filter(Customer__email_adresse__exact=
self.cleaned_data['email_adresse']
    raise forms.ValidationError(u'Cette adresse Email est deja
utilisee')
    return self.cleaned_data
except:
    pass


If you have beter idea.

regards

Alain
Entry.objects.filter(blog__name__exact='Beatles Blog')


On 25 oct, 21:01, youpsla <[email protected]> wrote:
> Hello,
>
> I've setup a 5 steps form (There is only one table in the database).
> In the first step I ask for Email adresse. I ike this to be unique in
> the database.
>
> By putting parameters "unique=True" in models, the error only raise
> when submitting the form at the last step.
>
> Is there a way to do the lookup in the database when going from step 0
> (the one with Email field) to step 1. If Email adress already exist in
> the database, I like the step 0 form to be refreshed. Instead, go to
> step 1.
>
> Can somebody give me a way of doing this ?
>
> Regards
>
> Alain

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

Reply via email to