On Wed, Jul 7, 2010 at 6:22 PM, Nick <nickt...@gmail.com> wrote:
> I am working on a form to resend an account activation email for newly
> registered users who did not receive their first email.
>
> The form is currently raising a DoesNotExist error and I can't figure
> out why:
>
> Here is the activation code:
>
> class resend_activation(forms.Form):
>    email = forms.EmailField(label="E-Email")
>
>    def clean_email(self):
>        email = self.cleaned_data["email"]
>
>        try:
>            FullProfile.objects.get(email=email)
>        except FullProfile.DoesNotExist:
>
>         test =
> FullProfile.objects.get(email=self.cleaned_data['email'])
>         raise forms.ValidationError("%s" % (test))

It's tricky to see with the line wrapping:

1) You try to get a FullProfile object
2) If it doesn't exist, you try to get it again. This causes the
uncaught DoesNotExist exception.
3) If it does exist, you immediately raise a validation error.

Looks like your logic is incorrect.

>
>    def send(self):
>        email = self.cleaned_data['email']
>        user = FullProfile.objects.get(email=email)
>        thread = Thread(target=send_activation, args=[user])
>        thread.setDaemon(True)
>        thread.start()
>
> Here is the view:
>
> def resend(request):
>    if request.method == 'POST':
>        form = resend_activation(request.POST)
>        if form.is_valid():
>            resend = form.send()
>
>
>            return HttpResponseRedirect("../activate_message")
>    else:
>        form = resend_activation()
>
>    return render_to_response("registration/resend.html", {'form':
> form })
>
> Everytime I try to use the form I get a "FullProfile matching query
> does not exist." error. But in the above code I added a little test to
> see if the query was returning any values and it is. I have no clue
> why this portion of process is holding up everything else.
>

I see no little test.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to