On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> > you simply override the save() function to do what you described:
> > create another instance and mark this one as deleted...
> That's what I want to do....
>
> > what is now in 'm' ?? the new object, the one merked for deletion? etc.
> > if you only need this in admin, then you shouldn't have to worry about
> > this, though I am not 100% sure. But if you want to use some other
> > code with such a model you would have to be careful about that.
> This is my problem too. So, what to do now exactly? A little example
> would be nice, and please mark which is the old instance and which is
> the new instance...

something like:

def save( self ):
    old_data = self.__class__.objects.get(pk=self.id).__dict__
    old_data['deleted'] = True
    self.__class__.objects.create( **old_data )
    super( models.Model, self ).save()

then when you do

m = Model.objects.get(pk=42)
m.some_field='some new value'
m.save()

another object will appear in your DB, m will be the updated object

you should add some transaction support, check if anything has changed
etc, but it should work...

>
> Thx
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to