Code Monkey home page Code Monkey logo

django-deletes's People

Contributors

ankitml avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-deletes's Issues

A restore method on the model

Restores a deleted instance of a Deletable model.
(Need to decide if it restores just the instance or all cascading instances. )

Option to periodically clean up table

Usually users do not care about old records, deleted records. Soft delete is mostly used for keeping a buffer or some kind of safety mechanism that saves the users data in unnecessary delete option. In the long run it doesnt make sense to keep old records and a clean up action may be desirable.

all_with_deleted doesn't work with related managers

  1. Say we delete a parent model. Parent model will be soft deleted. With all_with_delete() function we can still extract that parent model. While fetching its related models(which might be deleted as well) with all_with_deleted() gives me all the rows in that models rather than particular set which were related and deleted.

question = Question.objects.all()[100]
question.delete() - Corresponsing Answers are also deleted here

deleted_question = Question.objects.all_with_deleted(pk=q.id)
deleted_question.answers.count() give 0 which is fine
deleted_question.answers.all_with_deleted gives me all the answers rather than answer deleted and related to "deleted_question"

Restore keeping track of deletion history

Restore is either cascade or single object restore. There is no way to restore according to the objects that were deleted along with a specific deletion request.

Option to physically delete

  1. expose the old delete method.
  2. Cascades the old delete to cascading instances
  3. Can be either of the form:
    1. instance.delete(forced=True)
    2. instance.final_delete()

DeletableModelAdmin

list_display_filter = ("deleted", )
def get_queryset(self, request):
qs = self.model._default_manager.all_with_deleted()
if self.ordering:
qs = qs.order_by(*ordering)

Line 14: shouldn't it be *self.odering instead of *ordering

and: Line 9: list_filter instead list_display_filter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.