djangocms-attributes-field
Adds attributes to Django models.
What it is and what it does
This package provides an opinionated JSONField implementation for Django models that need to store arbitrary HTML element attributes without creating separate database columns or related tables for each attribute type. It solves the problem of managing flexible, schema-less attributes like data-* attributes or custom HTML properties that would otherwise require either many individual model fields or complex relational structures.
The package includes an AttributesField that stores key-value pairs as JSON and an AttributesWidget that provides an intuitive admin interface for editing these pairs. It automatically excludes dangerous keys like 'src', 'href', 'data', 'action', and any key starting with 'on' to prevent unintended JavaScript execution. The field also provides a convenience property that renders stored attributes as an HTML-safe string ready for template inclusion.
Use it for:
- Store custom data-* attributes on Django model instances without creating separate fields for each attribute type.
- Manage flexible HTML element attributes in a Django CMS plugin or page extension without schema migration overhead.
- Build admin forms where content editors can add arbitrary key-value pairs to HTML elements with a user-friendly widget interface.
- Avoid performance problems from excessive database columns or join tables when a model needs to support many optional attributes.
- Render HTML elements with dynamic attributes in templates by using the field's _str property for safe, escaped output.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Django model field and widget for storing and managing arbitrary HTML element attributes as JSON, with validation and template-safe string rendering.
Yes. This package is actively maintained, has no known vulnerabilities, carries a permissive license, and solves a real problem for Django projects that need flexible HTML attributes. The low install friction and single dependency on django-cms make it a straightforward addition to Django CMS sites. Use it when you need to store arbitrary attributes without schema bloat.
Install
djangocms-attributes-field on PyPI
pip
pip install djangocms-attributes-fielduv
uv add djangocms-attributes-fieldpoetry
poetry add djangocms-attributes-fieldInstalling djangocms-attributes-field
Before you install
Low install friction with a single runtime dependency on django-cms. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
BSD-3-Clause is a permissive license; you can use, modify, and distribute this package with minimal restrictions, provided you include the license notice.
Quickstart
pip install djangocms-attributes-field
# In models.py
from djangocms_attributes_field.fields import AttributesField
class MyCoolModel(models.Model):
attributes = AttributesField()
# In template
<div {{ object.attributes_str }}>click me</div>
Requires django-cms as a runtime dependency and Python 3.9 or later.
Verify before relying
- Performance characteristics when storing large numbers of attributes or very large attribute values in a single field.
- Specific Django and Django CMS version compatibility beyond the classifiers listed (4.2, 5.0, 5.1, 5.2 for Django; 3.11, 4.1, 5.0 for Django CMS).
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — django-cms |
| Maintenance | actively maintained — 285 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 82,253/month — #14,174 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: djangocms_attributes_field-4.1.2-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
django-cmsdjango CMS is a Django-based content management…
permissive · top 15,000 on PyPI
django-json-widgetProvides a rich JSON editor widget for Django's…
permissive · top 5,000 on PyPI
djangocms-text-ckeditorIntegrates CKEditor (v4.17.2) as a text editing…
permissive · top 15,000 on PyPI
django-multiselectfieldAdds model and form fields to Django that let…
copyleft · top 5,000 on PyPI
djangocms-admin-styleProvides styled CSS templates and admin…
permissive · top 15,000 on PyPI
jsonfieldA Django model field that stores and retrieves…
permissive · top 5,000 on PyPI
django-js-assetAdds script, stylesheet, and JSON tags with…
permissive · top 5,000 on PyPI
django-multi-email-fieldProvides Django model and form fields to store…
unclear · top 15,000 on PyPI
contentstack-utilsRenders embedded content and rich-text fields…
permissive · top 15,000 on PyPI
django-filerDjango Filer is a file and image management…
permissive · top 15,000 on PyPI