Skip to main content

Your project description goes here

Project description

https://badge.fury.io/py/django-anonymizable-model.svg/?style=flat-square https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square Coverage Status

Your project description goes here

Documentation

The full documentation is at https://django-anonymizable-model.readthedocs.io.

Quickstart

Install django-anonymizable-model:

pip install django-anonymizable-model

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'anonymizable_model',
    ...
)

Use on your models like this:

@anonymizable(
    db_label_prefix="pa_",
    anonymizable_fields=["first_name", "last_name", "phone_number"]
)
class ExampleGDPRModel(models.Model):
    objects = ExampleGDPRModelManager.from_queryset(ExampleGDPRModelQuerySet)()

    first_name = models.CharField("First name", max_length=255)
    last_name = models.CharField("Last name", max_length=255)
    phone_number = models.CharField("Phone number", max_length=255, blank=True, default="")
    description = models.TextField("Description", blank=True, default="")

It is possible to change db_label_prefix with your own label and assign anonymizable fields from the model for export and visualization features.

And then run migrations:

$ python manage.py makemigrations
$ python manage.py migrate

For the admin visualization use AnonymizableAdminMixin class:

@admin.register(ExampleGDPRModel)
class ExampleGDPRModelAdmin(AnonymizableAdminMixin, admin.ModelAdmin):
    list_display = (
        "__str__",
        "first_name",
        "last_name",
        "phone_number",
        "description",
    )

    fieldsets = (
        (None, {"fields": (
            ("first_name", "last_name"),
            ("phone_number", "description"),
        )}),
    )

The admin can view all anonymized data in fields. If a staff user does not have can_view_anonymized_fields permission all the data in anonymizable_fields will be substituted with “…”.

Anonymize DATABASE

It is possible to anonymize data directly in database using:

$ python manage.py anonymize_database

Features

  • Remove or override __str__ method to display “…” if user does not have permission

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Development commands

pip install -r requirements_dev.txt
invoke -l

Credits

Tools used in rendering this package:

History

0.1.7 (2021-10-11)

  • First release on PyPI.

0.1.8 (2021-10-12)

  • Updated version for github actions

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-anonymizable-model-0.1.8.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

django_anonymizable_model-0.1.8-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-anonymizable-model-0.1.8.tar.gz.

File metadata

  • Download URL: django-anonymizable-model-0.1.8.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django-anonymizable-model-0.1.8.tar.gz
Algorithm Hash digest
SHA256 154f4a08a112273e4268e470f22ff6c506d2c8cc5f878ef54667f6329130c1b9
MD5 ef2bfc5082525bec4f50579a05b2f9fd
BLAKE2b-256 186b89390382e082f81f1f776d3f26aa22b6825f25c30d775aaa7ed3c7155716

See more details on using hashes here.

File details

Details for the file django_anonymizable_model-0.1.8-py2.py3-none-any.whl.

File metadata

  • Download URL: django_anonymizable_model-0.1.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django_anonymizable_model-0.1.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 90f9792210b6b5943fb3a45fe57b9cc36d4538d87baa66a1693f11e72b2ccfbf
MD5 b52fc3a76289396e29d11fe7d7d6249b
BLAKE2b-256 0445d18a936d34298571c23ec64ff648f142be7f3a7c4d21cc10086a017c1ec4

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