{"id":26121587,"url":"https://github.com/webu/django-neuralyzer","last_synced_at":"2025-10-06T12:48:33.283Z","repository":{"id":280828261,"uuid":"943336215","full_name":"webu/django-neuralyzer","owner":"webu","description":"Anonymize specific django model for specific instance","archived":false,"fork":false,"pushed_at":"2025-06-18T12:41:18.000Z","size":250,"stargazers_count":3,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-22T10:43:52.621Z","etag":null,"topics":["anonymization","django","gdpr"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-05T14:45:25.000Z","updated_at":"2025-06-21T18:26:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"af3ef279-9e95-403b-bdd1-47b9cf0c0f84","html_url":"https://github.com/webu/django-neuralyzer","commit_stats":null,"previous_names":["webu/django-neuralyzer"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/webu/django-neuralyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webu%2Fdjango-neuralyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webu%2Fdjango-neuralyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webu%2Fdjango-neuralyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webu%2Fdjango-neuralyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webu","download_url":"https://codeload.github.com/webu/django-neuralyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webu%2Fdjango-neuralyzer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270069357,"owners_count":24521790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anonymization","django","gdpr"],"created_at":"2025-03-10T14:24:04.309Z","updated_at":"2025-10-06T12:48:28.251Z","avatar_url":"https://github.com/webu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Neuralyzer\n\n[![PyPi - version](https://img.shields.io/pypi/v/django-neuralyzer.svg?style=flat-square)](https://pypi.python.org/pypi/django-neuralyzer)\n[![Licence](https://img.shields.io/pypi/l/django-neuralyzer.svg?style=flat-square)](https://pypi.python.org/pypi/django-neuralyzer)\n[![Python version](https://img.shields.io/pypi/pyversions/django-neuralyzer.svg?style=flat-square)](https://pypi.python.org/pypi/django-neuralyzer)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json\u0026style=flat-square)](https://github.com/charliermarsh/ruff)\n\nAnonymize instance data according to your need (GDPR, used in not-so-safe environments... )\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/webu/django-neuralyzer/blob/main/zebu-django-neuralizer.jpg\"/\u003e\n\u003c/p\u003e\n\n**Heavily inspired by [django-anon](https://github.com/Tesorio/django-anon/)**\n\nLike `django-anon`, `django-neuralyzer` will help you anonymize your model instance so it can be shared among developers, helping to reproduce bugs and make performance improvements in a production-like environment.\n\nIt also provide ability to target specific instance and not the whole database at once, so it can be use for GDPR compliance or \"forget about be\" feature of your app.\n\n## Usage\n\nUse `django-neuralyzer.BaseNeuralyzer` to define your neuralyzer classes:\n\n```py\nfrom django_neuralyzer.base import BaseNeuralyzer\n\nfrom your_app.models import Person\n\nclass PersonNeuralyzer(BaseNeuralyzer):\n   email = \"example@anonymized.org\"\n\n   # You can use static values instead of callables\n   is_admin = False\n\n   class Meta:\n      model = Person\n\n# run neuralyzer: be cautious, this will affect your current database!\nperson = Person.objects.last()\n\n# neuralyze full table:\nPersonNeuralyzer().run()\n\n# neuralyze only some instance\nPersonNeuralyzer().run(filters={\"pk\": person.pk})\n```\n\n### Lazy attributes\n\nLazy attributes can be defined as inline lambdas or methods, as shown below, using the `lazy_attribute` function/decorator.\n\n```py\nfrom django_neuralyzer.base import BaseNeuralyzer, lazy_attribute\n\nfrom your_app.models import Person\n\nclass PersonNeuralyzer(BaseNeuralyzer):\n   name = lazy_attribute(lambda o: 'x' * len(o.name))\n\n   @lazy_attribute\n   def date_of_birth(self):\n      \"\"\"Keep year and month\"\"\"\n      return self.date_of_birth.replace(day=1)\n\n   class Meta:\n      model = Person\n```\n\n## Management command\n\nFirst, to have access to the management command, you need to register the app\n\n```py\nINSTALLED_APPS = [\n  ...\n  \"django_neuralyzer\",\n  ...\n]\n```\n\n2 management command are given:\n\n1. `ensure_fields_are_handled` command\n2. `export_neuralyzed_fields` command\n\n### Ensure that all fields are neuralyzed\n\nEnsure that all field of your model are handle by the neuralyzer:\n\n```shell\ndjango-manage ensure_fields_are_handled\n```\n\nIf you want to ensure a field is handled, but you don't want to change its value, you can set it to `NEURALYZER_NOOP`:\n\n```py\nfrom django_neuralyzer.base import BaseNeuralyzer, NEURALYZER_NOOP\n\nfrom your_app.models import Person\n\nclass PersonNeuralyzer(BaseNeuralyzer):\n   id = NEURALYZER_NOOP\n   name = lazy_attribute(lambda o: 'x' * len(o.name))\n\n   class Meta:\n      model = Person\n```\n\nthis way, `ensure_fields_are_handled` will not complain that `id` is not handled.\n\n### Export neuralyzed fields\n\nIt may be handy to export what fields are neuralyzed and how. Run the\n\n```shell\ndjango-manage export_neuralyzed_fields\n```\n\nand a `neuralyzed_fields.csv` will be created at the root of your application.\n\nIn order to document the `lazy_attribute`, the docstring of the function will be used to document how this field is neuralyzed.\n\n## Why neuralyzer ?\n\nIn [Men in Black](https://meninblack.fandom.com/wiki/Neuralyzer), a \"neuralyzer\" is a tool that wipe the mind of anybody who sees the flash via isolating and editing certain element of their memory.\n\nThis is exactly what this django package intent to do (remove or fake some attributes of instances), so we find it funny to name it like that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebu%2Fdjango-neuralyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebu%2Fdjango-neuralyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebu%2Fdjango-neuralyzer/lists"}