--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
def save(self):
if self.only_me:
only_me_true = MyModel.objects.filter(only_me=True)
for obj in only_me_true:
obj.only_me = False
obj.save()
MyModel.save(self)
> >> django-users...@googlegroups.com<django-users%2Bunsubscribe@goo
> >>glegroups.com> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users...@googlegroups.com<django-users%2Bunsubscribe@goog
> >legroups.com> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
--
What Did Santa Claus Bring You In 1999? (#2)
WEBMASTER OF LINUXSUPERMEGAPORTAL.COM: One of my in-laws gifted me a
CD-ROM containing the text of every "...For Dummies" book ever published.
It's a shame IDG never published "Hiring A Hitman To Knock Off Your
Inlaws... For Dummies", because that's something I'm itching to do. At any
rate, I'm using the CD as a beer coaster.
JESSE BERST: I got a coupon redeemable for the full copy of Windows 2000
when it comes out in February. Win2K is the most innovative,
enterprise-ready, stable, feature-enriched, easy-to-use operating system
on the market. I don't see how Linux can survive against Microsoft's far
superior offering. I ask you: could you get fired for NOT choosing Windows
2000? You bet.
LINUX CONVERT: I kept hinting for a SGI box, but instead my wife got me an
old Packard Bell. Unfortunately, she bought it at CompUSSR, which doesn't
take returns, so I'm stuck with it. I haven't been able to get Linux to
boot on it, so this machine will probably become a $750 paperweight.
Sorry for the bad formatting -- hope this helps.
def save(self, *args, **kwargs):
if self.only_me:
only_me_true = MyModel.objects.filter(only_me=True)
for obj in only_me_true:
if obj.id != self.id:
obj.only_me = False
obj.save()
super(MyModel, self).save(*args, **kwargs)
Mike
--
What upsets me is not that you lied to me, but that from now on I can no
longer believe you.
-- Nietzsche
I just rechecked the django docs, the reason post_save() doesn't work is cause
post save is at the _end_ of the save method, end isn't after the save is
executed, but after all the instructions are executed in the save method. Yes
everytime you call save(), even in the loop that bit of code is getting called
all the time.
You should update this in the model admin after the save is complete, send a
custom single or call a manager method (mangers are meant ot work at the table
level, as opposed to models working on the row level) or put this code bit in
a function you call in the model admin after saving. Ideally I would put it
in a custom singal and send that after the save, where ever I needed it.
Mike
--
Do people know you have freckles everywhere?
def save(self, force_insert=False, force_update=False):
if self.only_me is True:
# if this is the new default, set others to False
MyModel.objects.exclude(pk=self.pk).update(only_me=False)
super(MyModel, self).save(force_insert, force_update) # Call the "real" save() method.
--
Eric Chamberlain, Founder
RF.com - http://RF.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.