A Django field that enables convenient soft-deletion. For Python 2.7/3.3+ and Django 1.8+
Simple: pip install django-livefield.
>>>fromdjango.dbimportmodels>>>fromlivefieldimportLiveField, LiveManager>>>>>>>>>classPerson(models.Model): ... name=models.CharField() ... alive=LiveField() ... ... objects=LiveManager() ... all_objects=LiveManager(include_soft_deleted=True) ... ... classMeta: ... unique_together= ('name', 'alive') ... ... defdelete(self, using=None): ... self.alive=False ... self.save(using=using) ... >>>john=Person.objects.create(name='John Cleese') >>>doppelganger=Person(name='John Cleese') >>>doppelganger.save() # Raises an IntegrityError>>>john.delete() >>>doppelganger.save() # Succeeds!MIT. See LICENSE.txt for details.
Pull requests welcome! To save everyone some hassle, please open an issue first so we can discuss your proposed change.
In your PR, be sure to add your name to AUTHORS.txt and include some tests for your spiffy new functionality. Travis CI will green-light your build once it passes the unit tests (./setup.py test) and our linters (./lint.sh).