{"id":21137,"library":"django-anon","title":"django-anon","description":"django-anon is a Django library that helps anonymize production data so it can be safely used in non-production environments. It provides model mixins and field anonymization functions. The current version is 0.3.2. Release cadence is sporadic; last release was in 2019.","status":"active","version":"0.3.2","language":"python","source_language":"en","source_url":"https://github.com/Tesorio/django-anon","tags":["django","anonymization","data-sanitization","security"],"install":[{"cmd":"pip install django-anon","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for model fields and querysets","package":"django","optional":false},{"reason":"Provides fake data generators","package":"faker","optional":false}],"imports":[{"note":"Direct import from top-level package is correct.","wrong":"from django_anon.models import AnonymousUser","symbol":"AnonymousUser","correct":"from django_anon import AnonymousUser"},{"note":"No common wrong import known.","symbol":"AnonymizationMixin","correct":"from django_anon.mixins import AnonymizationMixin"},{"note":"No common wrong import known.","symbol":"fake_email","correct":"from django_anon.fields import fake_email"}],"quickstart":{"code":"import os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project.settings')\nimport django\ndjango.setup()\n\nfrom django_anon import AnonymousUser\nfrom myapp.models import User\n\nfor user in User.objects.all()[:1]:\n    anon_user = AnonymousUser(user)\n    print(anon_user.email)\n    print(anon_user.username)","lang":"python","description":"Basic usage: create an AnonymousUser instance from an existing model instance and access anonymized fields."},"warnings":[{"fix":"Always call super().save() after anonymization in custom save methods.","message":"If you override save() in your model and call anonymize(), ensure you call super() to avoid infinite loops. Version 0.3.2 fixed a similar infinite loop in fake_username with empty separator.","severity":"gotcha","affected_versions":"<=0.3.2"},{"fix":"Use Django's native bulk_update instead of relying on django-anon's version.","message":"The built-in bulk_update method changed in Django 2.2. django-anon 0.3 uses Django's built-in method if available, but there may be edge cases.","severity":"deprecated","affected_versions":"0.3"},{"fix":"Set max_size explicitly when calling fake_email if you need longer addresses.","message":"The fake_email function default max_size changed from infinite to 40 in version 0.3. This can cause emails to be truncated if you expect longer ones.","severity":"breaking","affected_versions":"0.3"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add import os; os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project.settings'); import django; django.setup() before using django-anon.","cause":"Calling django_anon functions without setting up Django settings first.","error":"django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured."},{"fix":"Use correct import: from django_anon import AnonymousUser. Verify installation with 'pip list | grep django-anon'.","cause":"Trying to import from the wrong path, or the library is not installed correctly.","error":"AttributeError: module 'django_anon' has no attribute 'AnonymousUser'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}