{"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,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}