Your project description goes here
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-anonymizable-model-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 154f4a08a112273e4268e470f22ff6c506d2c8cc5f878ef54667f6329130c1b9 |
|
MD5 | ef2bfc5082525bec4f50579a05b2f9fd |
|
BLAKE2b-256 | 186b89390382e082f81f1f776d3f26aa22b6825f25c30d775aaa7ed3c7155716 |
Hashes for django_anonymizable_model-0.1.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f9792210b6b5943fb3a45fe57b9cc36d4538d87baa66a1693f11e72b2ccfbf |
|
MD5 | b52fc3a76289396e29d11fe7d7d6249b |
|
BLAKE2b-256 | 0445d18a936d34298571c23ec64ff648f142be7f3a7c4d21cc10086a017c1ec4 |