Skip to main content

Simple Djanngo module to anonymize production data for safe usage on none production environments

Project description

django-anonymous

Simple Djanngo module to anonymize production data for safe usage on none production environments.

Installation

pip install django-anonymous

Usage

In your app create a file anon.py:

from django_anonymous import Anonymizer, Faker, register
from .model import YourModel


@register(YourModel)
class YourModelAnonymizer(Anonymizer):
    
    # You can give any callable, Faker is a small wrapper around the `faker` library. 
    email = Faker("email", unique=True)
    
    # You can also use any static value
    first_name = "Anon"

Run the anonymizer

python manage.py anonymize

Custom QuerySet

You can set a custom QuerySet to filter out some objects

from django_anonymous import Anonymizer, Faker, register
from .model import YourModel


@register(YourModel)
class YourModelAnonymizer(Anonymizer):
    email = Faker("email", unique=True)

    def get_queryset(self):
        return super().get_queryset().filter(is_staff=True)

Settings for Anonymizer

Per Anonymizer you can set the select chunk size and update batch size.

from django_anonymous import Anonymizer, Faker, register
from .model import YourModel


@register(YourModel)
class YourModelAnonymizer(Anonymizer):
    SELECT_CHUNK_SIZE = 100
    UPDATE_BATCH_SIZE = 25
    
    email = Faker("email", unique=True)

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-anonymous-0.1.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_anonymous-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file django-anonymous-0.1.0.tar.gz.

File metadata

  • Download URL: django-anonymous-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for django-anonymous-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2fd7af6fcb1d47c5a9e878159ca40f082f3463d41b5aab2e79febca92d9d3f8f
MD5 9b546b6993beede236ff10b289dd5550
BLAKE2b-256 cc934b43108308df183b38701f312d30eb66a0cba86028a6c516c36d7d579f75

See more details on using hashes here.

File details

Details for the file django_anonymous-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_anonymous-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for django_anonymous-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0da7cfe218f0f130c6669016503727031bc97e1feccd363666e282060d5bfb27
MD5 d4f17572e76a6d8630e646ea9b6fec4a
BLAKE2b-256 46fd652bfd5780e9d357a36374765d5d912a0574f12e87232b7e7f5d38a3c947

See more details on using hashes here.

Supported by

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