skillfed

djangocms-attributes-field

Adds attributes to Django models.

djangocms-attributes-field v4.1.2 82.3K downloads/30d#14,174 on PyPI28
Permissive license BSD-3-Clause Active released

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-field

uv

uv add djangocms-attributes-field

poetry

poetry add djangocms-attributes-field

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django CMSFramework :: Django CMS :: 3.11Framework :: Django CMS :: 4.1Framework :: Django CMS :: 5.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software DevelopmentTopic :: Software Development :: Libraries

Tags

django html attributes fieldjson field html attributesdjango model attributes storagekey-value html attributes djangodjango cms attributes widgethtml element attributes djangojson attributes field django
django-cmshtml-attributesjson-field

More Software Development packages

typing-extensions

Provides backported and experimental type hints…

permissive · top 100 on PyPI

numpy

NumPy provides an N-dimensional array object…

permissive · top 100 on PyPI

fastapi

FastAPI is a Python web framework for building…

permissive · top 100 on PyPI

annotated-doc

Provides a way to document function parameters,…

permissive · top 100 on PyPI

typer

Typer builds command-line applications from…

permissive · top 1,000 on PyPI

distlib

Distlib provides low-level packaging utilities…

permissive · top 1,000 on PyPI

django-cms

django CMS is a Django-based content management…

permissive · top 15,000 on PyPI

django-json-widget

Provides a rich JSON editor widget for Django's…

permissive · top 5,000 on PyPI

djangocms-text-ckeditor

Integrates CKEditor (v4.17.2) as a text editing…

permissive · top 15,000 on PyPI

django-multiselectfield

Adds model and form fields to Django that let…

copyleft · top 5,000 on PyPI

djangocms-admin-style

Provides styled CSS templates and admin…

permissive · top 15,000 on PyPI

jsonfield

A Django model field that stores and retrieves…

permissive · top 5,000 on PyPI

django-js-asset

Adds script, stylesheet, and JSON tags with…

permissive · top 5,000 on PyPI

django-multi-email-field

Provides Django model and form fields to store…

unclear · top 15,000 on PyPI

contentstack-utils

Renders embedded content and rich-text fields…

permissive · top 15,000 on PyPI

django-filer

Django Filer is a file and image management…

permissive · top 15,000 on PyPI