Skip to main content

Creates a pg_dumpish output which masks data without saving changes to the source database.

Project description

Django Mask Postgres Data

Adds a management command to your Django project which allows you to create a (sort of) pg_dump of your data with sensitive data masked.


Install with pip:

pip install django-maskpostgresdata

And add maskpostgresdata to your INSTALLED_APPS:



By default, django-maskpostgresdata will replace the password column for each row in the Django User model with "password". Just run dump_masked_data and you'll get a pg_dump with the password field changed to "password" for all users.

There are 2 ways to customise the behaviour of django-maskpostgresdata.

To override individual fields of a model with a given value, add a dictionary called MASKER_FIELDS to your settings using the following format:

    "{ APP_NAME }": {"{ MODEL_NAME }": {"{ FIELD_NAME }": { VALUE },}},

Alternatively, you can define exactly how the data is updated by subclassing BasePostgresDataMaskingCommand in a management command of your own. For example:

from django.contrib.auth.hashers import make_password

from maskpostgresdata import BasePostgresDataMaskingCommand

class Command(BasePostgresDataMaskingCommand):

    def update_auth_user(self, queryset):

Just create a method called update_{ db_table_name } taking a queryset as the parameter. You can then perform update operations on this queryset. { db_table_name } is of the format {app_label}_{model_name} by default, but could technically be different.

You can then run dump_masked_data and it will dump your data to stdout.

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-maskpostgresdata-0.2.1.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

django_maskpostgresdata-0.2.1-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

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