Registry / database / django-pgcrypto-fields

django-pgcrypto-fields

JSON →
library2.6.0pypypiunverified

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
INSTALL
IMPORT
SIG · DJANGO-PGCRYPTO-FI
D
django-pgcrypto-fields
databasepythonv2.6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TextPGPSymmetricKeyField
from pgcrypto import TextPGPSymmetricKeyField
from pgcrypto.fields import TextPGPSymmetricKeyField

Define an encrypted field. Auto-encrypts on save, auto-decrypts on read.

import os from django.db import models from pgcrypto.fields import TextPGPSymmetricKeyField class MyModel(models.Model): name = models.CharField(max_length=100) secret = TextPGPSymmetricKeyField() # Usage # Ensure PGCRYPTO_KEY environment variable is set (e.g., export PGCRYPTO_KEY='mysecretkey') # Then create and query normally; encryption/decryption is automatic. obj = MyModel.objects.create(name='test', secret='sensitive data') print(obj.secret) # Outputs 'sensitive data' (decrypted)
Debug
Known issues
breakingPGPManager 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.
affects: >=2.4.0
breakingAggregates module removed in v2.4.0. Use standard Django aggregates instead.
fix
Remove imports from pgcrypto.aggregates.
affects: >=2.4.0
gotchaEncryption 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.
affects: all
deprecatedPython 3.5 support dropped in v2.6.0. Use Python >=3.6.
fix
Upgrade Python to 3.6+.
affects: 2.6.0+
Upgrade
Version history
2.6.0latest on PyPI · released Jan 6, 2021
Audit
Dependencies
DjangorequiredRequired: Django ORM integration
psycopg2requiredRequired for PostgreSQL connection
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
django-pgcrypto-fields — pip install django-pgcrypto-fields · libregistry