Monday, January 26, 2015

Re: forloop

Thank you for your email. I am iterating all the row to find out which row was recently added. basically when a row is added to it become last. so i am trying to comparing a column on the last row. which is the row that was recently add if the condition of the column is exist. that is when i send out email.

hope my explanation is clear.

Cheers


On Tue, Jan 27, 2015 at 10:28 AM, Paul Royik <distantjob004@gmail.com> wrote:
Inside view there is no forloop (unless you explicitly define it). forloop is defined only inside for loops in templates

Actually your code is somewhat weird.
You iterate all list until last without doing anything.

It is more efficient to use slicing

email = newleave.objects.all()[-1] # this is already last item
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') 

Other code is also not very understandable, but I can't help you, since don't understand what should be done.

--
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/ac2740f3-2e60-44f7-860d-974550476cd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

--
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-y51_QA6iLbJnyvLQSkdL6SCu8x%3DO8P2vjVeWcBsd9rCWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment