diff --git a/anonymiser/models.py b/anonymiser/models.py index e043800..5efac38 100644 --- a/anonymiser/models.py +++ b/anonymiser/models.py @@ -133,12 +133,15 @@ def is_field_redaction_auto(self, field: models.Field) -> bool: """ Return True if the field should be auto-redacted. + Return False if the class-level auto_redact attr is False. + Currently this includes text fields that are not choices, primary keys, unique fields, or in the auto_redact_exclude list. """ return ( - isinstance(field, (models.CharField, models.TextField)) + self.auto_redact + and isinstance(field, (models.CharField, models.TextField)) and not field.choices and not field.primary_key and not getattr(field, "unique", False)