Registry / web-framework / django-colorfield

django-colorfield

JSON →
library0.14.0pypypi✓ verified 24d ago

django-colorfield is a simple color field for Django models, providing a user-friendly color-picker widget in the Django admin interface. It supports various color formats including HEX, HEXA, RGB, and RGBA. The library is actively maintained, with version 0.14.0 recently released, and typically sees updates for new Django and Python versions.

pip install django-colorfield
INSTALL
IMPORT
SIG · DJANGO-COLORFIELD
D
django-colorfield
web-frameworkpythonv0.14.0
Install
2.2s avg
Import
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.14.0 · 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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 37.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.000s · 39MB
36MB installed
● package 36MB
Code
Verified usage

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

ColorField
from colorfield.fields import ColorField
from colorfield.fields import ColorField

To quickly get started, install the package, add 'colorfield' to your `settings.INSTALLED_APPS`, and then define `ColorField`s in your Django models. After modifying `INSTALLED_APPS`, remember to run `python manage.py collectstatic` for the color picker to appear correctly in the admin. The `ColorField` automatically provides a color picker in the Django admin interface.

import os from django.db import models from colorfield.fields import ColorField # settings.py modification: # INSTALLED_APPS = [ # ..., # 'colorfield', # ..., # ] # After adding 'colorfield' to INSTALLED_APPS, run 'python manage.py collectstatic'. class Product(models.Model): name = models.CharField(max_length=100) # Default format is HEX main_color = ColorField(default='#FFFFFF') # Example with RGBA format background_color = ColorField(format="hexa", default='#000000FF') def __str__(self): return f"{self.name} ({self.main_color})"
Debug
Known issues
breakingVersion 0.14.0 replaced the underlying JavaScript color picker library from `jscolor` to `coloris`. If you had custom JavaScript or styling that directly interacted with `jscolor`, this will be a breaking change and require updates.
fix
Review any custom JavaScript or CSS related to the color picker. Refer to the `coloris` documentation for its API and styling, and update your code accordingly.
affects: 0.14.0+
breakingSupport for older Python and Django versions has been progressively dropped. Version 0.8.0 dropped Python < 3.8 and Django < 2.2. Version 0.9.0 dropped Django 2.2. Later versions (e.g., 0.13.0) added support for Django 5.2, indicating continued forward compatibility but no backward compatibility with very old versions.
fix
Ensure your project runs on Python 3.8+ and Django 4.2+ (or newer compatible versions as per releases). Upgrade your Python and Django environments if necessary.
affects: 0.8.0+
gotchaThe `max_length` of the `ColorField` was increased from 18 to 25 in version 0.10.1 to properly accommodate new formats like RGBA. If you relied on the previous `max_length` for database schema or custom validation, this change might require a database migration or adjustment of your validation rules.
fix
If you are upgrading from a version older than 0.10.1 and have existing `ColorField`s, ensure you run `makemigrations` and `migrate` after updating to reflect the new `max_length` in your database schema. Review any custom validation that assumes a `max_length` of 18.
affects: 0.10.1+
Upgrade
Version history
0.14.0latest on PyPI · released Apr 30, 2025
Audit
Dependencies
DjangorequiredCore framework dependency. Supports Django >= 4.2 up to 5.2.
Agent activity
12 hits · last 30 days
node
10
Resources
django-colorfield — pip install django-colorfield · libregistry