django-anonymizer2 / docs / overview.rst


  • Generate some anonymizers for your apps:

    ./ create_anonymizers app_name1 [app_name2...]

    This will create a file in each of the apps you specify. (It will not overwrite existing files).

    The file will contain autogenerated classes that attempt to use appropriate functions for generating fake data.

  • Edit the generated files.

    You will mainly need to edit the :attr:`~anonymizer.base.Anonymizer.attributes` list:

    • Choose an appropriate 'replacer' from the :mod:`anonymizer.replacers` module.
    • For some fields, you will want to remove them from the list of attributes, so that the values will be unchanged - especially things like denormalised fields.
    • Some models may not need any anonymization, and the corresponding anonymizer can be deleted.
  • If you need to create anonymizers for apps that you do not control, you may want to move the contents of the file to an app that you do control. It doesn't matter if the anonymizer classes are for models that do not correspond to the applications they are contained it.

    (For example, if you want to anonymize the models in django.contrib.auth, you will probably want to move the contents of django/contrib/auth/ into yourprojectapp/

  • Run the anonymizers:

    ./ anonymize_data app_name1 [app_name2...]

    This will DESTRUCTIVELY UPDATE all your data. Make sure you only do this on a copy of your database, use at own risk, yada yada.

  • Note: your database may not actually delete the changed data from the disk when you update fields. For Postgresql you will need to VACUUM to delete that data.

    And even then, your operating system may not delete the data from the disk. Properly getting rid of these traces is left as an excercise to the reader :-)