Monday, January 26, 2015

Re: forloop

Here is how it looks like, when a new row is added it display last.


On Tue, Jan 27, 2015 at 10:51 AM, Stephen J. Butler <stephen.butler@gmail.com> wrote:
Do you have a default ordering on the Model object? That is, an
ordering option on newleave.Meta? Because otherwise this query
"newleave.objects.all()" is not at all guaranteed to return rows in
the order they were added.

It may, by coincidence, in your current environment behave that way.
But change databases, or add more rows, or look at it funny, and that
won't be true.

On Mon, Jan 26, 2015 at 5:38 PM, sum abiut <suabiut@gmail.com> wrote:
> 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.

--
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/CAD4ANxX4Rw0ke_VnrEQHYt-1BgYo0Nouy3rbL%3Dk-Pnn4Sq%3DmUA%40mail.gmail.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-y4puiNqfe%2BFeoGzeYBRF8QkWYW6dUG2U_zdAcSDbzcjBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment