{"id":23614,"library":"djangocms-attributes-field","title":"django CMS Attributes Field","description":"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.","status":"active","version":"4.1.2","language":"python","source_language":"en","source_url":"https://github.com/django-cms/djangocms-attributes-field/","tags":["django-cms","attributes","django","html"],"install":[{"cmd":"pip install djangocms-attributes-field","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Required by the field","package":"django","optional":false},{"reason":"Optional, needed for integration with django CMS","package":"django-cms","optional":true}],"imports":[{"note":"The module is 'fields' not the top-level package","wrong":"from djangocms_attributes_field import AttributesField","symbol":"AttributesField","correct":"from djangocms_attributes_field.fields import AttributesField"},{"note":"There is no 'forms' module; form field is also in 'fields'","wrong":"from djangocms_attributes_field.forms import AttributesFormField","symbol":"AttributesFormField","correct":"from djangocms_attributes_field.fields import AttributesFormField"}],"quickstart":{"code":"import os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_settings')\n\nimport django\nfrom django.conf import settings\nsettings.configure(\n    DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}},\n    INSTALLED_APPS=['djangocms_attributes_field'],\n    DEFAULT_AUTO_FIELD='django.db.models.BigAutoField',\n)\ndjango.setup()\n\nfrom django.db import models\nfrom djangocms_attributes_field.fields import AttributesField\n\nclass MyModel(models.Model):\n    attributes = AttributesField(blank=True, default=dict)\n\n# Save and retrieve\ninstance = MyModel.objects.create(attributes={'class': 'my-class', 'data-id': '42'})\nprint(instance.attributes)\n","lang":"python","description":"Basic model with AttributesField including default and example usage."},"warnings":[{"fix":"Upgrade to Django >=4.2 and Python >=3.9 before upgrading to 4.x.","message":"Version 4.0.0 dropped support for Django 3.2, 4.0, 4.1 and Python 3.6, 3.7, 3.8.","severity":"breaking","affected_versions":"<4.0"},{"fix":"Review excluded keys in settings: DJANGOCMS_ATTRIBUTES_FIELD_EXCLUDED_KEYS.","message":"Version 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.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Always set default=dict on the field to avoid None values.","message":"AttributesField stores data as JSON; empty dict vs None can cause differences in DB querying.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'-2':46 '-5.1':36 '1':45 '3.2':35 '3.9':39 '4.1.2':32 'add':28 'allow':25 'arbitrari':10 'attribut':3,12,30,54 'cadenc':41 'cms':2,22,53 'common':18 'custom':29 'django':1,6,21,34,52,55 'django-cm':51 'editor':26 'field':4,7 'html':11,56 'irregular':43 'key':15 'key-valu':14 'minor':47 'pair':17 'per':49 'plugin':23 'python':38 'releas':40 'rough':44 'store':9 'support':33 'use':19 'valu':16 'version':31,48 'year':50","created_at":"2026-05-01T08:08:42.507649+00:00","updated_at":"2026-05-01T08:08:42.507649+00:00","problems":[{"fix":"Use: from djangocms_attributes_field.fields import AttributesField","cause":"Incorrect import path; the class is in the 'fields' submodule.","error":"ImportError: cannot import name 'AttributesField' from 'djangocms_attributes_field'"},{"fix":"Add 'djangocms_attributes_field' to your INSTALLED_APPS setting.","cause":"Missing 'djangocms_attributes_field' in INSTALLED_APPS.","error":"django.core.exceptions.ImproperlyConfigured: 'djangocms_attributes_field' is not a valid Django app"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.1.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/django-cms/djangocms-attributes-field","docs":null,"changelog":null,"pypi":"https://pypi.org/project/djangocms-attributes-field/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}