Code Monkey home page Code Monkey logo

pinax-models's Introduction

Pinax Models

image

image

image

image

image

image

Pinax

Pinax is an open-source platform built on the Django Web Framework. It is an ecosystem of reusable Django apps, themes, and starter project templates. This collection can be found at http://pinaxproject.com.

This app was developed as part of the Pinax ecosystem but is just a Django app and can be used independently of other Pinax apps.

pinax-models

pinax-models provides support for logical deletes on models and in the Django admin.

This is a small and simple app that Patrick Altman wrote to get some reuse out of something he did in nearly every project and every model he created. It's too easy for good data to get deleted and it be unrecoverable. It's also too easy to fix this by overriding the model's delete() method and just flagging records as deleted and then leveraging Django's managers to override default behavior so that logically deleted items are not returned in querysets.

There are two exceptions to this rule, however, that are useful.

  1. In the admin it is nice to see everything with an indicator of whether or not it has been deleted, with the ability to filter down to just active records, (or deleted for that matter).
  2. It is a valid request when an item is fetched by its primary key value, that the object should return, even if it is marked as deleted.

History

On May 25, 2015, Patrick donated django-logicaldelete to Pinax and as part of that process, pinax-models was born and the code incorporated into that package. It remains just a Django app and can be quite independently of other Pinax apps.

Installation

pip install pinax-models

Usage

Using the app is pretty simple:

  1. add pinax.models to your INSTALLED_APPS
  2. Inherit from pinax.models.LogicalDeleteModel for all models that you wish to share in this functionality.
  3. Create and/or Register admins for each of these models using pinax.models.LogicalDeleteModelAdmin

Additional

Logical deletes are handled by date stamping a date_removed column. In addition, a date_created and date_modified columns will be populated as a convenience.

Backwards Incompatible Changes

2.0

  • Renamed to pinax-models and base model renamed to LogicalDeleteModel

1.1

  • Changed everything to all_with_deleted on LogicalDeleteManager
  • LogicalDeleteManager moved from logicaldelete.models to logicaldelete.managers
  • Removed deleted and everything querysets from logicaldelete.models.Model

Documentation

The pinax-models documentation is currently under construction. If you would like to help us write documentation, please join our Pinax Project Slack channel and let us know! The Pinax documentation is available at http://pinaxproject.com/pinax/.

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a code of conduct, which can be found here http://pinaxproject.com/pinax/code_of_conduct/.

Pinax Project Blog and Twitter

For updates and news regarding the Pinax Project, please follow us on Twitter at @pinaxproject and check out our blog http://blog.pinaxproject.com.

pinax-models's People

Contributors

paltman avatar psychok7 avatar angvp avatar jeffbowen avatar binarymatt avatar

Watchers

James Cloos avatar  avatar

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.