django-pgcrypto-fields

raw JSON →
2.6.0 verified Sat May 09 auth: no python

Provides encrypted model fields for Django using pgcrypto (PostgreSQL extension). Automatically encrypts/decrypts data via pgcrypto functions. Latest version 2.6.0 supports Django 2.2–3.1 and Python ≥3.6. Monthly or quarterly releases.

pip install django-pgcrypto-fields
error django.core.exceptions.ImproperlyConfigured: 'PGCRYPTO_KEY' environment variable is not set.
cause The symmetric key required by pgcrypto fields is missing.
fix
Set PGCRYPTO_KEY environment variable (e.g., export PGCRYPTO_KEY='your-key' in shell, or set in Django settings with os.environ).
error AttributeError: module 'pgcrypto' has no attribute 'aggregates'
cause Trying to import pgcrypto.aggregates which was removed in v2.4.0.
fix
Use standard Django aggregates (.count(), .sum(), etc.). Remove any imports from pgcrypto.aggregates.
error ImportError: cannot import name 'PGPManager' from 'pgcrypto.managers'
cause PGPManager removed in v2.4.0.
fix
Remove PGPManager from model managers; use default Django manager or a custom manager.
breaking PGPManager and PGPAdmin were removed in v2.4.0. Auto-decryption is now automatic; remove any references to these classes.
fix Use regular Django managers and admins, or no manager at all.
breaking Aggregates module removed in v2.4.0. Use standard Django aggregates instead.
fix Remove imports from pgcrypto.aggregates.
gotcha Encryption keys are read from environment variables PGCRYPTO_KEY (symmetric) or public/private key paths for public key fields. Not setting these will cause errors.
fix Ensure PGCRYPTO_KEY is set in your environment or Django settings.
deprecated Python 3.5 support dropped in v2.6.0. Use Python >=3.6.
fix Upgrade Python to 3.6+.