Registry / web-framework / djangocms-attributes-field

djangocms-attributes-field

JSON →
library4.1.2pypypi✓ verified 90d ago

A Django field that stores arbitrary HTML attributes as key-value pairs, commonly used with django CMS plugins to allow editors to add custom attributes. Version 4.1.2 supports Django 3.2-5.1 and Python 3.9+. Release cadence is irregular, roughly 1-2 minor versions per year.

pip install djangocms-attributes-field
INSTALL
IMPORT
SIG · DJANGOCMS-ATTRIBUT
D
djangocms-attributes-field
web-frameworkpythonv4.1.2
Install
5.0s avg
Import
625ms
Disk
93MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.616s · 88.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 5.0s · import 0.634s · 89MB
93MB installed
● package 93MB
Code
Verified usage

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

AttributesField
✓ from djangocms_attributes_field.fields import AttributesField
✗ from djangocms_attributes_field import AttributesField
The module is 'fields' not the top-level package
AttributesFormField
✓ from djangocms_attributes_field.fields import AttributesFormField
✗ from djangocms_attributes_field.forms import AttributesFormField
There is no 'forms' module; form field is also in 'fields'

Basic model with AttributesField including default and example usage.

import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_settings') import django from django.conf import settings settings.configure( DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}, INSTALLED_APPS=['djangocms_attributes_field'], DEFAULT_AUTO_FIELD='django.db.models.BigAutoField', ) django.setup() from django.db import models from djangocms_attributes_field.fields import AttributesField class MyModel(models.Model): attributes = AttributesField(blank=True, default=dict) # Save and retrieve instance = MyModel.objects.create(attributes={'class': 'my-class', 'data-id': '42'}) print(instance.attributes)
Debug
Known issues
breakingVersion 4.0.0 dropped support for Django 3.2, 4.0, 4.1 and Python 3.6, 3.7, 3.8.
fix
Upgrade to Django >=4.2 and Python >=3.9 before upgrading to 4.x.
affects: <4.0
breakingVersion 4.0.0 added form field validation from the model field; existing forms may throw validation errors if attributes contain keys in default_excluded_keys.
fix
Review excluded keys in settings: DJANGOCMS_ATTRIBUTES_FIELD_EXCLUDED_KEYS.
affects: >=4.0.0
gotchaAttributesField stores data as JSON; empty dict vs None can cause differences in DB querying.
fix
Always set default=dict on the field to avoid None values.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'AttributesField' from 'djangocms_attributes_field'
Incorrect import path; the class is in the 'fields' submodule.
fix
Use: from djangocms_attributes_field.fields import AttributesField
django.core.exceptions.ImproperlyConfigured: 'djangocms_attributes_field' is not a valid Django app
Missing 'djangocms_attributes_field' in INSTALLED_APPS.
fix
Add 'djangocms_attributes_field' to your INSTALLED_APPS setting.
Upgrade
Version history
4.1.2latest on PyPI · released Nov 2, 2025
Audit
Dependencies
djangorequiredRequired by the field
django-cmsoptionalOptional, needed for integration with django CMS
Agent activity
8 hits · last 30 days
node
8
Resources
djangocms-attributes-field — pip install djangocms-attributes-field · libregistry