Alex Gaynor wrote:
> On Thu, Aug 13, 2009 at 2:51 PM, Jonas Obrist<ojiido...@gmail.com> wrote:
>   
>> Hi django-users
>>
>> I try to do as much as I can in ORM without python looping etc. So I
>> wonder if the following code could be done in one update:
>>
>> for parent in thread.forum.allparents.all():
>>    parent.postcount += 1
>>    parent.lastpost = post
>>    parent.save()
>>
>> Basically do something like:
>>
>> thread.forums.allparents.update(postcount += 1, lastpost=post)
>>
>> I'm well aware that += is completely wrong there, it's just to
>> illustrate my idea.
>>
>> Jonas
>>
>>     
>
> If you're using django 1.1 you can use the new F() objects so it'd look like:
>
> thread.forums.allparents.update(postcount = F('postcount')+1, lastpost=post)
>
> Alex
>
>   
I read in the docs that F is for filters... but if that works, thanks!

Jonas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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