-
Website
http://www.codespatter.com -
Original page
http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
itjobs1
1 comment · 2 points
-
sikat ang pinoy
1 comment · 1 points
-
billymcclure
1 comment · 1 points
-
Ben Bangert
1 comment · 2 points
-
jakubmusil
1 comment · 1 points
-
-
Popular Threads
Say I import SoftDeleteManager from an external file and use it with objects = SoftDeleteManager()
But now, I loose ability to define additional custom manager methods because objecst is already assigned, right? Is there a way to solve this other than inheriting from multiple manager classes?
Metin
from somewhere import SoftDeleteManager
class NewManager(SoftDeleteManager):
'''new stuff'''
and in the model
objects = NewManager()
A simplified version of my issue works kind of like this: I have a lot of models that all derive from a base content class (articles, images, galleries, etc.). Articles are able to have related content (via a many to many field), but when I soft delete content, it'll still show up in related content queries on my articles. Is there a good way to get this method working for inherited classes and/or m2m fields?
Would overriding the models delete function, setting delete=True and saving suffice?
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.