I'm working on a web app where if a particular conditions is met in
particular object, a number of objects in another class/table need to
be altered. Basically a trigger, but I'm trying to keep all my logic
in the app for the time being. I'm wondering if there's a way to do
this with the Django DB API w/o falling back to raw sql.

A basic example is:

table foo
-----------
id
name
level


table bar
-------------
id
name
foo_id
switch


When foo.level drops to zero, I need to flip bar.switch like so...

update bar set switch = 0 where foo_id = foo.id and switch = 1

I could be updating any number of rows in bar. I want to do this
without do a select on bar.

Do I need to drop to raw sql, or have I missed this part of the Django
documentation?

Thanks for any feedback.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to