Skip to main content

Abstract Django models for soft removal

Project description

django-soft-remover

GitHub Actions PyPI PyPI - Python Version framework - Django PyPI - Django Version PyPI - License

Abstract Django models for soft removal.

It supports unique field indices specified with

  • unique
  • unique_together
  • UniqueConstraint (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

django-soft-remover-0.5.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

django_soft_remover-0.5.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

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

Hashes for django-soft-remover-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e791fea488eff3b01c16350dcd3aa5dcaf5922941fcdc5961c8852b387581cab
MD5 5eba63743ea68617a2b386ddf26f53c0
BLAKE2b-256 9585f036c801775998549c6afef79f3eb9b237cafe87c24e0eea75adac0d3d54

See more details on using hashes here.

File details

Details for the file django_soft_remover-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_soft_remover-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4db08c00e012bc88406a9f4b41d23282c129108986824cabc95cead5fabc0ad
MD5 319195e2d2b3981220f047afad29690c
BLAKE2b-256 11699b3086ba33e2f843b13b111f475f4a493036eb9b5d3d2f0fe002e220fb0b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page