I have the following code:
cd = form.cleaned_data
q = Subscription.objects.filter(product_key__exact = cd['product'])
q = q.filter(status__iexact='Active')
q = q.filter(term_length__gt=0)
# Decrement our terms remaining by 1.
rec_count = q.update(term_length=F('term_length') - 1)
return render_to_response('subs/shipped.html',{ 'q': q, 'rec_count': rec_count })
What happens is that the results I want to display on the "shipped" page are still being filtered according to the criteria I used to select the rows for updating. Since I have a >= 0 filter, I do not see those rows that were reduced from 1 to 0. I can't use {{ q|length }} to get number of records updated, for example.
How would I go about returning, for example, a list of the freshly updated records from BEFORE they were updated. I can't search after the fact, since status and term_length would be Inactive and 0 for a huge number of records; there will be nothing distinct about the ones that were last changed.
Thanks for the help.
M.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sxHCRgN2EGYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment