On 7/14/07, Steven Hilton <[EMAIL PROTECTED]> wrote:
> I could be updating any number of rows in bar. I want to do this
> without do a select on bar.
Also, it's worth noting that this is also fairly easy to do, it just
involves a little bit more code. Something like the following example
should get you started (this would be the save() method on the 'foo'
class, and a custom method also on that class):
def save(self):
super(Foo, self).save()
if self.level == 0:
self.switch_bar_set()
def switch_bar_set(self):
from django.db import backend, connection
query = """UPDATE %s SET %s = 0
WHERE %s = %%s
AND %s = 1""" % (Bar._meta.db_table,
backend.quote_name('switch'),
backend.quote_name('foo_id'),
backend.quote_name('switch'))
cursor = connection.cursor()
cursor.execute(query, [self.id])
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---