{"id":23568,"library":"django-cryptography-5","title":"django-cryptography","description":"django-cryptography provides encryption for Django model fields using AES. Current version 2.0.3, with a focus on simplicity and Django ORM integration. Release cadence is low; maintained by saaspegasus.","status":"active","version":"2.0.3","language":"python","source_language":"en","source_url":"https://github.com/saaspegasus/django-cryptography","tags":["django","encryption","fields","security"],"install":[{"cmd":"pip install django-cryptography","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Cryptographic operations","package":"pycryptodome","optional":true}],"imports":[{"note":"Old package name `encrypt` is deprecated; use `django_cryptography`.","wrong":"from encrypt.fields import EncryptedCharField","symbol":"EncryptedCharField","correct":"from django_cryptography.fields import EncryptedCharField"},{"note":"No common wrong import for this symbol.","symbol":"EncryptedTextField","correct":"from django_cryptography.fields import EncryptedTextField"},{"note":"Works with numeric types.","symbol":"EncryptedIntegerField","correct":"from django_cryptography.fields import EncryptedIntegerField"}],"quickstart":{"code":"import os\nimport django\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\ndjango.setup()\n\nfrom django_cryptography.fields import EncryptedCharField\nfrom django.db import models\n\nclass MyModel(models.Model):\n    secret = EncryptedCharField(max_length=255)\n\n# Now you can create and save instances normally:\ninstance = MyModel.objects.create(secret='my secret')\nprint(instance.secret)  # Output: 'my secret'","lang":"python","description":"Define an encrypted char field in a Django model."},"warnings":[{"fix":"Do not use encrypted fields in `filter()`, `order_by()`, or indexing. Consider using a non-encrypted field or hashing for lookups.","message":"Encrypted fields are not sortable or filterable by their encrypted values. Querying by encrypted field will not work as expected.","severity":"gotcha","affected_versions":"all"},{"fix":"Back up existing data before changing SECRET_KEY. Implement manual re-encryption if key rotation is needed.","message":"If you change the `SECRET_KEY` in Django settings, all existing encrypted data will become undecryptable. There is no built-in key rotation.","severity":"gotcha","affected_versions":"all"},{"fix":"Update imports to `from django_cryptography.fields import ...`","message":"The package was previously named `django-cryptography` and later `django-encrypt`? Actually, the correct import path changed from `encrypt` to `django_cryptography`. Ensure you are not using the old import.","severity":"deprecated","affected_versions":"<2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install it: `pip install pycryptodome`","cause":"Missing required dependency pycryptodome.","error":"ModuleNotFoundError: No module named 'pycryptodome'"},{"fix":"Use: `from django_cryptography.fields import EncryptedCharField`","cause":"Using deprecated import path from an older version of the package.","error":"ImportError: cannot import name 'EncryptedCharField' from 'encrypt.fields'"},{"fix":"Run `python manage.py makemigrations` and `python manage.py migrate`.","cause":"You forgot to run migrations after adding an encrypted field to your model.","error":"django.db.utils.OperationalError: no such column: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}