Skip to main content

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

Project description

django-anonymous

CI codecov License: GPL v3 PyPI version

Simple Djanngo module to anonymize production data for safe usage on non-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)

Inspired by

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.2.0.tar.gz (18.6 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.2.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-anonymous-0.2.0.tar.gz
  • Upload date:
  • Size: 18.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 f02404ded3898ef64885e1c91750f78ed51bd0ed802a61a75d07583451138dff
MD5 cad6f644d6ec0bd59f5f38e1974b91a7
BLAKE2b-256 d256e71654663d4fc00ad0da803772b5e55eab3a79d535add086cbdb525d7adb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_anonymous-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b458127a20d073b3eb248717b44318d8f922ec85240cd818d13d6881d9839e8
MD5 0b0a02d61983f8d2db7abfb41cf51438
BLAKE2b-256 a6f5e61296247f26c5262cc5b8474cefa1c388113d794f5ea88a1c3785921180

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