Monday, January 26, 2015

forloop

Hi,
i am getting an error as below when iterating throw rows. Basically what i want to do is iterate through number of rows. When on the last row i want to compare a  column then send out an email.

here is the error that i am getting:

global name 'forloop' is not defined


here is my view.py:

def email_authorizer(request):
    new_leave=newleave.objects.all()
    for email in new_leave:
        if forloop.last:
            govoffice=newleave.objects.filter(department="GOV")
            if govoffice.exists():
                to_emails = [u.email for u   in User.objects.filter(username__in['testuser','sabiut'])]
                send_mail("RBV Leave Application Email Testing", "You have received a leave application form. Please login to the leave system to Authorize the leave.",
                "RBV eLeave <Rbv_eLeave_System>", [to_emails])
                return render_to_response('thankyou.html')

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4K%2B%2BA2b9DMUn%2BUg9R6GcQzFeV-TivtpaeVZaweD0Vz7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment