Skip to main content

Django Anonymizable Model

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

Metadata

Release files for django-anonymizable-model 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-anonymizable-model 0.1.8
File Size Uploaded Provenance Actions
django-anonymizable-model-0.1.8.tar.gz 10.8 kB Without provenance Details for django-anonymizable-model-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-anonymizable-model 0.1.8
File Interpreter ABI Platform Actions
django_anonymizable_model-0.1.8-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_anonymizable_model-0.1.8-py2.py3-none-any.whl

Total release size: 19.4 kB

Release files / django-anonymizable-model-0.1.8.tar.gz

Download URL django-anonymizable-model-0.1.8.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
154f4a08a112273e4268e470f22ff6c506d2c8cc5f878ef54667f6329130c1b9
BLAKE2b-256 checksum
How to use checksums
186b89390382e082f81f1f776d3f26aa22b6825f25c30d775aaa7ed3c7155716
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / django_anonymizable_model-0.1.8-py2.py3-none-any.whl

Download URL django_anonymizable_model-0.1.8-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
90f9792210b6b5943fb3a45fe57b9cc36d4538d87baa66a1693f11e72b2ccfbf
BLAKE2b-256 checksum
How to use checksums
0445d18a936d34298571c23ec64ff648f142be7f3a7c4d21cc10086a017c1ec4
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for django-anonymizable-model 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page