{"id":13415789,"url":"https://github.com/fabiocaccamo/django-colorfield","last_synced_at":"2025-04-12T11:45:22.393Z","repository":{"id":37772171,"uuid":"645063","full_name":"fabiocaccamo/django-colorfield","owner":"fabiocaccamo","description":":art: color field for django models with a nice color-picker in the admin.","archived":false,"fork":false,"pushed_at":"2025-04-07T17:03:07.000Z","size":369,"stargazers_count":647,"open_issues_count":6,"forks_count":96,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-11T08:06:38.038Z","etag":null,"topics":["admin","color","colorfield","colorpicker","django","field","interface","jscolor","model","models","picker","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiocaccamo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fabiocaccamo"],"polar":"fabiocaccamo","ko_fi":"fabiocaccamo","liberapay":"fabiocaccamo","tidelift":"pypi/django-colorfield","custom":["https://www.buymeacoffee.com/fabiocaccamo","https://www.paypal.me/fabiocaccamo"]}},"created_at":"2010-05-03T20:19:39.000Z","updated_at":"2025-04-07T07:25:30.000Z","dependencies_parsed_at":"2024-01-11T19:15:34.097Z","dependency_job_id":"0feeb130-6422-42ef-b159-55abfb230135","html_url":"https://github.com/fabiocaccamo/django-colorfield","commit_stats":{"total_commits":353,"total_committers":34,"mean_commits":"10.382352941176471","dds":"0.38810198300283283","last_synced_commit":"32eeb5350ce7404852d688081e6edebe46d06f05"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fdjango-colorfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fdjango-colorfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fdjango-colorfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fdjango-colorfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiocaccamo","download_url":"https://codeload.github.com/fabiocaccamo/django-colorfield/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248564401,"owners_count":21125407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin","color","colorfield","colorpicker","django","field","interface","jscolor","model","models","picker","python"],"created_at":"2024-07-30T21:00:52.121Z","updated_at":"2025-04-12T11:45:22.372Z","avatar_url":"https://github.com/fabiocaccamo.png","language":"Python","funding_links":["https://github.com/sponsors/fabiocaccamo","https://polar.sh/fabiocaccamo","https://ko-fi.com/fabiocaccamo","https://liberapay.com/fabiocaccamo","https://tidelift.com/funding/github/pypi/django-colorfield","https://www.buymeacoffee.com/fabiocaccamo","https://www.paypal.me/fabiocaccamo"],"categories":["Third-Party Packages","Python","Packages to install at your project"],"sub_categories":["Model Fields","Models","Widgets / Fields"],"readme":"[![](https://img.shields.io/pypi/pyversions/django-colorfield.svg?color=3776AB\u0026logo=python\u0026logoColor=white)](https://www.python.org/)\n[![](https://img.shields.io/pypi/djversions/django-colorfield?color=0C4B33\u0026logo=django\u0026logoColor=white\u0026label=django)](https://www.djangoproject.com/)\n\n[![](https://img.shields.io/pypi/v/django-colorfield.svg?color=blue\u0026logo=pypi\u0026logoColor=white)](https://pypi.org/project/django-colorfield/)\n[![](https://static.pepy.tech/badge/django-colorfield/month)](https://pepy.tech/project/django-colorfield)\n[![](https://img.shields.io/github/stars/fabiocaccamo/django-colorfield?logo=github\u0026style=flat)](https://github.com/fabiocaccamo/django-colorfield/stargazers)\n[![](https://img.shields.io/pypi/l/django-colorfield.svg?color=blue)](https://github.com/fabiocaccamo/django-colorfield/blob/main/LICENSE.txt)\n\n[![](https://results.pre-commit.ci/badge/github/fabiocaccamo/django-colorfield/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/django-colorfield/main)\n[![](https://img.shields.io/github/actions/workflow/status/fabiocaccamo/django-colorfield/test-package.yml?branch=main\u0026label=build\u0026logo=github)](https://github.com/fabiocaccamo/django-colorfield)\n[![](https://img.shields.io/codecov/c/gh/fabiocaccamo/django-colorfield?logo=codecov)](https://codecov.io/gh/fabiocaccamo/django-colorfield)\n[![](https://img.shields.io/codacy/grade/194566618f424a819ce43450ea0af081?logo=codacy)](https://www.codacy.com/app/fabiocaccamo/django-colorfield)\n[![](https://img.shields.io/codeclimate/maintainability/fabiocaccamo/django-colorfield?logo=code-climate)](https://codeclimate.com/github/fabiocaccamo/django-colorfield/)\n[![](https://img.shields.io/badge/code%20style-black-000000.svg?logo=python\u0026logoColor=black)](https://github.com/psf/black)\n[![](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n# django-colorfield\nsimple color field for your models with a nice color-picker in the admin-interface.\n\n![django-colorfield-hex](https://user-images.githubusercontent.com/7900305/104512324-51ed0f80-55ee-11eb-9144-de03d922c2ce.png)\n![django-colorfield-hexa](https://user-images.githubusercontent.com/7900305/104512063-ec991e80-55ed-11eb-95b6-9174ac3f4f38.png)\n\n---\n\n## Installation\n-   Run `pip install django-colorfield`\n-   Add `colorfield` to `settings.INSTALLED_APPS`\n-   Run `python manage.py collectstatic`\n-   Restart your application server\n\n---\n\n## Usage\n\n### Settings\nThis package doesn't need any setting.\n\n### Models\nJust add color field(s) to your models like this:\n\n```python\nfrom colorfield.fields import ColorField\nfrom django.db import models\n\nclass MyModel(models.Model):\n    color = ColorField(default='#FF0000')\n```\n\n### Field Options\nThese are the supported custom options: [`format`](#format), [`image_field`](#image_field), [`samples`](#samples)\n\n#### format\n\nThe following formats are supported: `hex` *(default)*, `hexa`, `rgb`, `rgba`.\n\n```python\nfrom colorfield.fields import ColorField\nfrom django.db import models\n\nclass MyModel(models.Model):\n    color = ColorField(format=\"hexa\")\n```\n\n#### image_field\n\nIt is possible to auto-populate the field value getting the color from an image using the `image_field` option.\n\nThe color will be calculated from the **top-left pixel** color of the image each time the model instance is saved.\n\n```python\nfrom colorfield.fields import ColorField\nfrom django.db import models\n\nclass MyModel(models.Model):\n    image = models.ImageField(upload_to=\"images\")\n    color = ColorField(image_field=\"image\")\n```\n\n#### samples\n\nIt is possible to provide a palette of colors to choose from to the widget using the `samples` option.\n\nThis option **is not restrictive** (on the contrary of `choices` option), it is also possible to choose another color from the spectrum.\n\n![django-colorfield-samples](https://user-images.githubusercontent.com/7900305/104512178-194d3600-55ee-11eb-8cba-91cca156da06.png)\n\n```python\nfrom colorfield.fields import ColorField\nfrom django.db import models\n\nclass MyModel(models.Model):\n\n    COLOR_PALETTE = [\n        (\"#FFFFFF\", \"white\", ),\n        (\"#000000\", \"black\", ),\n    ]\n\n    # not restrictive, allows the selection of another color from the spectrum.\n    color = ColorField(samples=COLOR_PALETTE)\n\n    # restrictive, it is mandatory to choose a color from the palette\n    color = ColorField(choices=COLOR_PALETTE)\n```\n\n### Forms\n\n#### Model forms\n\nThe `colorfield.fields.ColorField` can be used in Django model forms (`django.forms.ModelForm`) to provide a color picker widget.\nWhen used in a model form, the field automatically validates the color format based on the specified `format` (e.g., `hex`, `rgb`, `rgba`).\n\n```python\nfrom django import forms\n\nclass MyModelForm(forms.ModelForm):\n    class Meta:\n        model = MyModel\n        fields = [\"color\"]\n```\n\n#### Plain forms\n\nThe `colorfield.forms.ColorField` can be used in plain Django forms (`django.forms.Form`) to provide a color-picker widget.\nThis is useful when you need a color input outside of a model context.\n\n```python\nfrom django import forms\nfrom colorfield.forms import ColorField\n\nclass MyForm(forms.Form):\n    color = ColorField(initial=\"#FF0000\", format=\"hex\")\n```\n\n### Admin\nThe admin will kindly provide a simple [color picker](http://jscolor.com/) for all color fields. :)\n\n---\n\n## Testing\n```bash\n# clone repository\ngit clone https://github.com/fabiocaccamo/django-colorfield.git \u0026\u0026 cd django-colorfield\n\n# create virtualenv and activate it\npython -m venv venv \u0026\u0026 . venv/bin/activate\n\n# upgrade pip\npython -m pip install --upgrade pip\n\n# install requirements\npip install -r requirements.txt -r requirements-test.txt\n\n# install pre-commit to run formatters and linters\npre-commit install --install-hooks\n\n# run tests\ntox\n# or\npython runtests.py\n# or\npython -m django test --settings \"tests.settings\"\n```\n---\n\n## Credits\nOriginally developed by [Jared Forsyth](https://github.com/jaredly)\n\n---\n\n## License\nReleased under [MIT License](LICENSE.txt).\n\n---\n\n## Supporting\n\n- :star: Star this project on [GitHub](https://github.com/fabiocaccamo/django-colorfield)\n- :octocat: Follow me on [GitHub](https://github.com/fabiocaccamo)\n- :blue_heart: Follow me on [Twitter](https://twitter.com/fabiocaccamo)\n- :moneybag: Sponsor me on [Github](https://github.com/sponsors/fabiocaccamo)\n\n## See also\n\n- [`django-admin-interface`](https://github.com/fabiocaccamo/django-admin-interface) - the default admin interface made customizable by the admin itself. popup windows replaced by modals. 🧙 ⚡\n\n- [`django-cache-cleaner`](https://github.com/fabiocaccamo/django-cache-cleaner) - clear the entire cache or individual caches easily using the admin panel or management command. 🧹✨\n\n- [`django-extra-settings`](https://github.com/fabiocaccamo/django-extra-settings) - config and manage typed extra settings using just the django admin. ⚙️\n\n- [`django-maintenance-mode`](https://github.com/fabiocaccamo/django-maintenance-mode) - shows a 503 error page when maintenance-mode is on. 🚧 🛠️\n\n- [`django-redirects`](https://github.com/fabiocaccamo/django-redirects) - redirects with full control. ↪️\n\n- [`django-treenode`](https://github.com/fabiocaccamo/django-treenode) - probably the best abstract model / admin for your tree based stuff. 🌳\n\n- [`python-benedict`](https://github.com/fabiocaccamo/python-benedict) - dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘\n\n- [`python-codicefiscale`](https://github.com/fabiocaccamo/python-codicefiscale) - encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. 🇮🇹 💳\n\n- [`python-fontbro`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations. 🧢\n\n- [`python-fsutil`](https://github.com/fabiocaccamo/python-fsutil) - file-system utilities for lazy devs. 🧟‍♂️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiocaccamo%2Fdjango-colorfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiocaccamo%2Fdjango-colorfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiocaccamo%2Fdjango-colorfield/lists"}