django-picklefield
Pickled object field for Django
What it is and what it does
django-picklefield extends Django models with a field type that transparently serializes and stores arbitrary Python objects in the database. Instead of manually pickling and unpickling data or designing a schema for each object type, you define a PickledObjectField and assign any picklable Python object to it—lists, dicts, custom classes, or nested structures—and the field handles encoding, storage, and retrieval automatically.
The package base64-encodes pickled data to ensure ASCII-safe storage across database backends and supports optional zlib compression, configurable pickle protocols, and database lookups (exact, in, isnull). It is designed for cases where a proper relational schema does not exist, such as storing configuration objects, cached computations, or heterogeneous data. The critical caveat is that pickle is inherently unsafe for untrusted input; the field is marked non-editable by default and should never receive unsanitized user data.
Use it for:
- Store configuration or settings objects in a Django model without designing a separate schema for each setting type.
- Cache computed Python objects (e.g., analysis results, transformed data) directly in the database for later retrieval.
- Persist application state or workflow context that does not fit a normalized relational structure.
- Store lookup tables or reference data as Python dicts or lists without creating additional database tables.
- Handle heterogeneous data in a single field when the object structure varies per record.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Django model field that stores and retrieves any picklable Python object directly in the database, handling serialization and deserialization automatically.
Yes, if you need to store non-relational Python objects in Django and trust the source of all data assigned to the field. The package is stable, actively maintained, and supports current Django and Python versions. Install only if you understand the pickle security implications and will never assign unsanitized user input to PickledObjectField.
Install
django-picklefield on PyPI
pip
pip install django-picklefielduv
uv add django-picklefieldpoetry
poetry add django-picklefieldInstalling django-picklefield
Before you install
Low install friction with a single Django dependency. Last release was 260 days ago; the repository is active and not archived, though maintenance status is aging. Supports current Python versions (3.10+) and recent Django versions through 6.0.
License in practice
MIT license is permissive and places no restrictions on use or redistribution. You may use this package in commercial or proprietary projects without obligation to share modifications.
Quickstart
pip install django-picklefield
from picklefield.fields import PickledObjectField
from django.db import models
class MyModel(models.Model):
data = PickledObjectField()
obj = MyModel()
obj.data = ['any', {'picklable': 'object'}]
obj.save()
Do not store untrusted user input directly in PickledObjectField; pickle.loads() can execute arbitrary code. The field is marked editable=False by default to prevent form exposure, but programmatic assignment of unsanitized data remains a security risk.
Verify before relying
- Whether the package's compression feature (compress=True) is actively used or maintained in production deployments.
- Performance characteristics when storing very large object trees, especially with the copy parameter set to False.
- Compatibility with database-specific pickle handling or edge cases beyond the tested Django/Python versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | aging — 260 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,327,233/month — #4,054 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_picklefield-3.4.0-py3-none-any.whl
Keywords: django, pickle, model, field
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
jsonfieldA Django model field that stores and retrieves…
permissive · top 5,000 on PyPI
pypicklepypickle wraps Python's pickle module to save…
permissive · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
django-versatileimagefieldExtends Django's ImageField with flexible image…
permissive · top 15,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
django-hashidsProvides a Django model field that proxies…
permissive · top 15,000 on PyPI
django-sqidsAdds a Django model field that encodes primary…
permissive · top 15,000 on PyPI
sqlitedictProvides a dict-like interface to SQLite…
permissive · top 5,000 on PyPI
jsonpicklejsonpickle converts complex Python objects to…
permissive · top 5,000 on PyPI