Abstract Django models for soft removal
Project description
django-soft-remover
Abstract Django models for soft removal.
It supports unique field indices specified with
uniqueunique_togetherUniqueConstraint(without expressions or conditions)
Just add the remver field to the composite unique index if you need to maintain uniqueness between removed versions.
Installation
$ pip install django-soft-remover
Example of use
from django.db import models
from soft_remover.models import SoftRemovableModel, SoftRestorableModel
class ManyUniqueTogetherRem(SoftRemovableModel):
category = models.CharField(max_length=32)
name = models.CharField(max_length=32)
tag = models.CharField(max_length=32)
value = models.PositiveSmallIntegerField()
class Meta:
unique_together = (('category', 'name', 'remver'), ('category', 'tag', 'remver'))
class UniqueWithConstraint(SoftRemovableModel):
name = models.CharField(max_length=32)
class Meta:
constraints = [
models.UniqueConstraint(fields=['name', 'remver'], name='uwc_name_remver'),
]
class ManyUniqueTogetherRes(SoftRestorableModel):
category = models.CharField(max_length=32)
name = models.CharField(max_length=32)
tag = models.CharField(max_length=32)
value = models.PositiveSmallIntegerField()
class Meta:
unique_together = (('category', 'name'), ('category', 'tag'))
See more examples in test models.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-soft-remover-0.5.0.tar.gz.
File metadata
- Download URL: django-soft-remover-0.5.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e791fea488eff3b01c16350dcd3aa5dcaf5922941fcdc5961c8852b387581cab
|
|
| MD5 |
5eba63743ea68617a2b386ddf26f53c0
|
|
| BLAKE2b-256 |
9585f036c801775998549c6afef79f3eb9b237cafe87c24e0eea75adac0d3d54
|
File details
Details for the file django_soft_remover-0.5.0-py3-none-any.whl.
File metadata
- Download URL: django_soft_remover-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4db08c00e012bc88406a9f4b41d23282c129108986824cabc95cead5fabc0ad
|
|
| MD5 |
319195e2d2b3981220f047afad29690c
|
|
| BLAKE2b-256 |
11699b3086ba33e2f843b13b111f475f4a493036eb9b5d3d2f0fe002e220fb0b
|