Source

django-anonymizer / docs / overview.rst

Luke Plant 17dfc7a 




















Luke Plant c13cc2b 






Luke Plant 17dfc7a 

























========
Overview
========

* Generate some anonymizers for your apps::

    ./manage.py create_anonymizers app_name1 [app_name2...]

  This will create a file ``anonymizers.py`` 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 ``anonymizers.py`` 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 specify "SKIP" so that the values will be
    unchanged - especially things like denormalised fields.

    Note that you can't just remove from the list. This is to cope with the
    problem of new fields being added to the model, but the developer forgetting
    to add the field to the anonymizer. To prevent that situation, every field
    must listed in the 'attributes' list.

  * 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 anonymizers.py 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/anonymizers.py``
  into ``yourprojectapp/anonymizers.py``)

* Run the anonymizers::

    ./manage.py 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 :-)