Re: Keeping track of the original values for a record...

2007-08-30 Thread [EMAIL PROTECTED]
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, "[EM

Re: Keeping track of the original values for a record...

2007-08-29 Thread [EMAIL PROTECTED]
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 a

Re: Keeping track of the original values for a record...

2007-08-29 Thread Doug B
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.

Re: Keeping track of the original values for a record...

2007-08-29 Thread [EMAIL PROTECTED]
Ahh..this appears to work! Thanks! On Aug 29, 3:46 pm, Michael <[EMAIL PROTECTED]> wrote: > You can simply override the __init__ method and take a copy of the > values then: > > See Malcolm's explanation > here:http://groups.google.com/group/django-users/msg/6d849eca95243371 > > -Mike > > On Au

Re: Keeping track of the original values for a record...

2007-08-29 Thread Michael
You can simply override the __init__ method and take a copy of the values then: See Malcolm's explanation here: http://groups.google.com/group/django-users/msg/6d849eca95243371 -Mike On Aug 30, 5:28 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I tried using the signals... but setting a

Re: Keeping track of the original values for a record...

2007-08-29 Thread [EMAIL PROTECTED]
I tried using the signals... but setting a new value on the record, seems to also set it on the _original_data ...which is odd...maybe I'm not seeing something stupid that I'm doing? If I change my marketing_status_name data in my view and save, the new data is in both the _original_data, and in

Re: Keeping track of the original values for a record...

2007-08-29 Thread Doug B
You could probably use the post_init signal to make a copy of the model values for comparison in your save method. I'm doing something similar to create a special manager object each time a certain model instance is created. Something like this... def backup_model_data(sender, instance, signal,

Re: Keeping track of the original values for a record...

2007-08-29 Thread George Vilches
Jure Čuhalev wrote: > On 8/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Since there isn't a load() method on a model... I'm thinking I somehow >> have to do this on the manager..but not sure ... any tips would be >> great. >> >> When I load a record, either via get() or by looping throug

Re: Keeping track of the original values for a record...

2007-08-29 Thread [EMAIL PROTECTED]
Thanks..but I'm already overriding save, and creating an event record... I need to know how to do something extra when the data is loaded initially. I know I could query the record again into a new object and use that for the original values..but that seems pretty hackish ...so I'd prefer to

Re: Keeping track of the original values for a record...

2007-08-29 Thread Jure Čuhalev
On 8/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Since there isn't a load() method on a model... I'm thinking I somehow > have to do this on the manager..but not sure ... any tips would be > great. > > When I load a record, either via get() or by looping through the > results of a .fil

Keeping track of the original values for a record...

2007-08-29 Thread [EMAIL PROTECTED]
Since there isn't a load() method on a model... I'm thinking I somehow have to do this on the manager..but not sure ... any tips would be great. When I load a record, either via get() or by looping through the results of a .filter(), I'd like to keep track of the original attribute values via set