Comments on: A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/ Tue, 12 May 2020 19:23:12 +0000 http://wordpress.org/?v=2.8.4 hourly 1 By: Nitin Nain http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15393 Nitin Nain Tue, 12 May 2020 19:23:12 +0000 http://codespatter.com/?p=467#comment-15393 <p>There's so much great content like this that you don't get to because of Google's search algorithm! Instead all that you see on Google are posts on Medium by some college chump trying to plug their biodata :/</p> There's so much great content like this that you don't get to because of Google's search algorithm! Instead all that you see on Google are posts on Medium by some college chump trying to plug their biodata :/

]]>
By: How can I easily mark records as deleted in Django models instead of actually deleting them? – Loitools.com http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15391 How can I easily mark records as deleted in Django models instead of actually deleting them? – Loitools.com Sun, 16 Feb 2020 23:33:05 +0000 http://codespatter.com/?p=467#comment-15391 [...] A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin [...] [...] A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin [...]

]]>
By: the martian http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15367 the martian Mon, 30 Mar 2015 03:18:01 +0000 http://codespatter.com/?p=467#comment-15367 <strong>the martian...</strong> A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin | Code Spatter... the martian…

A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin | Code Spatter…

]]>
By: simply click the following web site http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15315 simply click the following web site Fri, 16 May 2014 02:44:16 +0000 http://codespatter.com/?p=467#comment-15315 <strong>simply click the following web site...</strong> A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin | Code Spatter... simply click the following web site…

A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin | Code Spatter…

]]>
By: black http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15305 black Tue, 30 Nov 2010 15:16:21 +0000 http://codespatter.com/?p=467#comment-15305 <p>Hello, Your thoughts is very helpful for us . Thanks</p> Hello, Your thoughts is very helpful for us . Thanks

]]>
By: black http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15237 black Tue, 30 Nov 2010 09:16:21 +0000 http://codespatter.com/?p=467#comment-15237 Hello, Your thoughts is very helpful for us . Thanks Hello, Your thoughts is very helpful for us . Thanks

]]>
By: Guetux http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15236 Guetux Sun, 28 Nov 2010 00:24:43 +0000 http://codespatter.com/?p=467#comment-15236 Thank you, this helped me a lot!<br><br>BTW, with django 1.2 and the new multi db support, unfortunatley this doesn't work anymore, as the save_base method prunes the deleted objects with by calling the using(foo) method on the manager. To make this on still work, SoftDeleteManager needs to define something like this:<br><br> def using(self, *args, **kwargs):<br> ''' Needed to support multi db infrastructure since django 1.2'''<br> return self.all_with_deleted().using(*args, **kwargs) <br><br>Unfortunatley this removes the possibility of this "hack" to work with multiple dbs...<br><br>Anyway, it still helped me a lot, thanks again! Thank you, this helped me a lot!

BTW, with django 1.2 and the new multi db support, unfortunatley this doesn't work anymore, as the save_base method prunes the deleted objects with by calling the using(foo) method on the manager. To make this on still work, SoftDeleteManager needs to define something like this:

def using(self, *args, **kwargs):
''' Needed to support multi db infrastructure since django 1.2'''
return self.all_with_deleted().using(*args, **kwargs)

Unfortunatley this removes the possibility of this “hack” to work with multiple dbs…

Anyway, it still helped me a lot, thanks again!

]]>
By: Greg Allard http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15191 Greg Allard Mon, 10 Aug 2009 14:11:07 +0000 http://codespatter.com/?p=467#comment-15191 That would work. If you are using a signal (pre_delete or post_delete), you might need to send it from the new function since you wouldn't want to call the real delete.<br><br>I've been doing object.deleted = 1 object.save() and not calling or overriding delete(). That way I still have the option to do the real delete in case I need it. You could probably make a real_delete() function to do that if needed though. That would work. If you are using a signal (pre_delete or post_delete), you might need to send it from the new function since you wouldn't want to call the real delete.

I've been doing object.deleted = 1 object.save() and not calling or overriding delete(). That way I still have the option to do the real delete in case I need it. You could probably make a real_delete() function to do that if needed though.

]]>
By: Dave http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15190 Dave Mon, 10 Aug 2009 11:17:49 +0000 http://codespatter.com/?p=467#comment-15190 I think I must be missing something, as I cant see where you're setting the flag "deleted".<br><br>Would overriding the models delete function, setting delete=True and saving suffice? I think I must be missing something, as I cant see where you're setting the flag “deleted”.

Would overriding the models delete function, setting delete=True and saving suffice?

]]>
By: Greg Allard http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/comment-page-1/#comment-15185 Greg Allard Wed, 22 Jul 2009 19:37:32 +0000 http://codespatter.com/?p=467#comment-15185 I tested this out with a simple many to many example and I am not getting the soft deleted objects returned. With objects = SoftDeleteManager the many to many queries will be using get_query_set() which won't return the soft deleted records. I might need to see an example of how you are getting the deleted results to be able to figure out what is going on. I tried it with some_object.related_things.all() and the returned set won't have deleted related_things. I tested this out with a simple many to many example and I am not getting the soft deleted objects returned. With objects = SoftDeleteManager the many to many queries will be using get_query_set() which won't return the soft deleted records. I might need to see an example of how you are getting the deleted results to be able to figure out what is going on. I tried it with some_object.related_things.all() and the returned set won't have deleted related_things.

]]>