Blah... I could have sworn that worked when I tried it yesterday..... but when I went to start working on it today..that method is returning the changed values as well... very strange... I might have to resort to calling the values from the DB again before doing a save :(
On Aug 29, 4:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Maybe it's a bug in my branch..I'm using the multiple db branch... but > the other method Mike pointed out appears to work. Tomorrow I'm going > to tie it all together and have my save method only fire save if there > are dirty fields, and log what data has been changed into my event > table... > > Thanks again everyone! > > On Aug 29, 4:13 pm, Doug B <[EMAIL PROTECTED]> wrote: > > > Hmm. It works in shell for me, I'm not sure what the difference might > > be. It only keeps _original_data for the life of the instance, so if > > the view completes, the next view is a different instance. You could > > make a pickle field to persist it, if you wanted to keep track of the > > changed values. > > > In [2]: m=cm.MarketingStatus(marketing_status_name="Test Name", > > marketing_status_description="Testing signals") > > In [3]: m.save() > > In [4]: m.marketing_status_name="Changed this" > > In [5]: m.marketing_status_name > > Out[5]: 'Changed this' > > In [6]: m._original_data['marketing_status_name'] > > Out[6]: 'Test Name' > > > I added a couple print statements to print testing and testing 2 in > > the save method: > > > In [2]: m=cm.MarketingStatus.objects.all()[0] > > In [3]: m.marketing_status_name = "changed again" > > In [4]: m.save() > > testing: Test Name > > testing2: changed again > > > ----- using this code ---- > > def backup_model_data(sender, instance, signal, *args, **kwargs): > > instance._original_data = instance.__dict__.copy() > > > class MarketingStatus(models.Model): > > marketing_status_id = models.AutoField(primary_key=True) > > marketing_status_name = models.CharField(blank=True, maxlength=30) > > marketing_status_description = > > models.CharField(blank=True,maxlength=255) > > > def save(self): > > testing =self._original_data['marketing_status_name'] > > testing2 = self.marketing_status_name > > print "testing: %s" % testing > > print "testing2: %s" % testing2 > > super(MarketingStatus, self).save() > > > dispatcher.connect(backup_model_data,signal=signals.post_init,sender=MarketingStatus) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---