Name | django-colorfield JSON |
Version |
0.11.0
JSON |
| download |
home_page | |
Summary | color field for django models with a nice color-picker in the admin. |
upload_time | 2023-12-05 22:44:07 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | MIT License Copyright (c) 2013-present Jared Forsyth / Fabio Caccamo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
django
colorfield
colorpicker
color
field
picker
chooser
admin
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![](https://img.shields.io/pypi/pyversions/django-colorfield.svg?color=3776AB&logo=python&logoColor=white)](https://www.python.org/)
[![](https://img.shields.io/pypi/djversions/django-colorfield?color=0C4B33&logo=django&logoColor=white&label=django)](https://www.djangoproject.com/)
[![](https://img.shields.io/pypi/v/django-colorfield.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/django-colorfield/)
[![](https://static.pepy.tech/badge/django-colorfield/month)](https://pepy.tech/project/django-colorfield)
[![](https://img.shields.io/github/stars/fabiocaccamo/django-colorfield?logo=github)](https://github.com/fabiocaccamo/django-colorfield/stargazers)
[![](https://img.shields.io/pypi/l/django-colorfield.svg?color=blue)](https://github.com/fabiocaccamo/django-colorfield/blob/main/LICENSE.txt)
[![](https://results.pre-commit.ci/badge/github/fabiocaccamo/django-colorfield/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/django-colorfield/main)
[![](https://img.shields.io/github/actions/workflow/status/fabiocaccamo/django-colorfield/test-package.yml?branch=main&label=build&logo=github)](https://github.com/fabiocaccamo/django-colorfield)
[![](https://img.shields.io/codecov/c/gh/fabiocaccamo/django-colorfield?logo=codecov)](https://codecov.io/gh/fabiocaccamo/django-colorfield)
[![](https://img.shields.io/codacy/grade/194566618f424a819ce43450ea0af081?logo=codacy)](https://www.codacy.com/app/fabiocaccamo/django-colorfield)
[![](https://img.shields.io/codeclimate/maintainability/fabiocaccamo/django-colorfield?logo=code-climate)](https://codeclimate.com/github/fabiocaccamo/django-colorfield/)
[![](https://img.shields.io/badge/code%20style-black-000000.svg?logo=python&logoColor=black)](https://github.com/psf/black)
[![](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
# django-colorfield
simple color field for your models with a nice color-picker in the admin-interface.
![django-colorfield-hex](https://user-images.githubusercontent.com/7900305/104512324-51ed0f80-55ee-11eb-9144-de03d922c2ce.png)
![django-colorfield-hexa](https://user-images.githubusercontent.com/7900305/104512063-ec991e80-55ed-11eb-95b6-9174ac3f4f38.png)
---
## Installation
- Run `pip install django-colorfield`
- Add `colorfield` to `settings.INSTALLED_APPS`
- Run `python manage.py collectstatic`
- Restart your application server
---
## Usage
### Settings
This package doesn't need any setting.
### Models
Just add color field(s) to your models like this:
```python
from colorfield.fields import ColorField
from django.db import models
class MyModel(models.Model):
color = ColorField(default='#FF0000')
```
### Field Options
These are the supported custom options: [`format`](#format), [`image_field`](#image_field), [`samples`](#samples)
#### format
The following formats are supported: `hex` *(default)*, `hexa`, `rgb`, `rgba`.
```python
from colorfield.fields import ColorField
from django.db import models
class MyModel(models.Model):
color = ColorField(format="hexa")
```
#### image_field
It is possible to auto-populate the field value getting the color from an image using the `image_field` option.
The color will be calculated from the **top-left pixel** color of the image each time the model instance is saved.
```python
from colorfield.fields import ColorField
from django.db import models
class MyModel(models.Model):
image = models.ImageField(upload_to="images")
color = ColorField(image_field="image")
```
#### samples
It is possible to provide a palette of colors to choose from to the widget using the `samples` option.
This option **is not restrictive** (on the contrary of `choices` option), it is also possible to choose another color from the spectrum.
![django-colorfield-samples](https://user-images.githubusercontent.com/7900305/104512178-194d3600-55ee-11eb-8cba-91cca156da06.png)
```python
from colorfield.fields import ColorField
from django.db import models
class MyModel(models.Model):
COLOR_PALETTE = [
("#FFFFFF", "white", ),
("#000000", "black", ),
]
# not restrictive, allows the selection of another color from the spectrum.
color = ColorField(samples=COLOR_PALETTE)
# restrictive, it is mandatory to choose a color from the palette
color = ColorField(choices=COLOR_PALETTE)
```
### Admin
The admin will kindly provide a simple [color picker](http://jscolor.com/) for all color fields. :)
---
## Testing
```bash
# clone repository
git clone https://github.com/fabiocaccamo/django-colorfield.git && cd django-colorfield
# create virtualenv and activate it
python -m venv venv && . venv/bin/activate
# upgrade pip
python -m pip install --upgrade pip
# install requirements
pip install -r requirements.txt -r requirements-test.txt
# install pre-commit to run formatters and linters
pre-commit install --install-hooks
# run tests
tox
# or
python runtests.py
# or
python -m django test --settings "tests.settings"
```
---
## Credits
Originally developed by [Jared Forsyth](https://github.com/jaredly)
---
## License
Released under [MIT License](LICENSE.txt).
---
## Supporting
- :star: Star this project on [GitHub](https://github.com/fabiocaccamo/django-colorfield)
- :octocat: Follow me on [GitHub](https://github.com/fabiocaccamo)
- :blue_heart: Follow me on [Twitter](https://twitter.com/fabiocaccamo)
- :moneybag: Sponsor me on [Github](https://github.com/sponsors/fabiocaccamo)
## See also
- [`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. ๐ง โก
- [`django-extra-settings`](https://github.com/fabiocaccamo/django-extra-settings) - config and manage typed extra settings using just the django admin. โ๏ธ
- [`django-maintenance-mode`](https://github.com/fabiocaccamo/django-maintenance-mode) - shows a 503 error page when maintenance-mode is on. ๐ง ๐ ๏ธ
- [`django-redirects`](https://github.com/fabiocaccamo/django-redirects) - redirects with full control. โช๏ธ
- [`django-treenode`](https://github.com/fabiocaccamo/django-treenode) - probably the best abstract model / admin for your tree based stuff. ๐ณ
- [`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. ๐
- [`python-codicefiscale`](https://github.com/fabiocaccamo/python-codicefiscale) - encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. ๐ฎ๐น ๐ณ
- [`python-fontbro`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations. ๐งข
- [`python-fsutil`](https://github.com/fabiocaccamo/python-fsutil) - file-system utilities for lazy devs. ๐งโโ๏ธ
Raw data
{
"_id": null,
"home_page": "",
"name": "django-colorfield",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "Fabio Caccamo <fabio.caccamo@gmail.com>",
"keywords": "django,colorfield,colorpicker,color,field,picker,chooser,admin,python",
"author": "",
"author_email": "Jared Forsyth <jared@jaredforsyth.com>, Fabio Caccamo <fabio.caccamo@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/18/c4/75a831118a0d213a7646b72af8cef264e43116c84083a0e24d2cdebc6102/django-colorfield-0.11.0.tar.gz",
"platform": null,
"description": "[![](https://img.shields.io/pypi/pyversions/django-colorfield.svg?color=3776AB&logo=python&logoColor=white)](https://www.python.org/)\n[![](https://img.shields.io/pypi/djversions/django-colorfield?color=0C4B33&logo=django&logoColor=white&label=django)](https://www.djangoproject.com/)\n\n[![](https://img.shields.io/pypi/v/django-colorfield.svg?color=blue&logo=pypi&logoColor=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)](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&label=build&logo=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&logoColor=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### 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 && cd django-colorfield\n\n# create virtualenv and activate it\npython -m venv venv && . 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. \ud83e\uddd9 \u26a1\n\n- [`django-extra-settings`](https://github.com/fabiocaccamo/django-extra-settings) - config and manage typed extra settings using just the django admin. \u2699\ufe0f\n\n- [`django-maintenance-mode`](https://github.com/fabiocaccamo/django-maintenance-mode) - shows a 503 error page when maintenance-mode is on. \ud83d\udea7 \ud83d\udee0\ufe0f\n\n- [`django-redirects`](https://github.com/fabiocaccamo/django-redirects) - redirects with full control. \u21aa\ufe0f\n\n- [`django-treenode`](https://github.com/fabiocaccamo/django-treenode) - probably the best abstract model / admin for your tree based stuff. \ud83c\udf33\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. \ud83d\udcd8\n\n- [`python-codicefiscale`](https://github.com/fabiocaccamo/python-codicefiscale) - encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. \ud83c\uddee\ud83c\uddf9 \ud83d\udcb3\n\n- [`python-fontbro`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations. \ud83e\udde2\n\n- [`python-fsutil`](https://github.com/fabiocaccamo/python-fsutil) - file-system utilities for lazy devs. \ud83e\udddf\u200d\u2642\ufe0f\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2013-present Jared Forsyth / Fabio Caccamo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "color field for django models with a nice color-picker in the admin.",
"version": "0.11.0",
"project_urls": {
"Documentation": "https://github.com/fabiocaccamo/django-colorfield#readme",
"Download": "https://github.com/fabiocaccamo/django-colorfield/releases",
"Funding": "https://github.com/sponsors/fabiocaccamo/",
"Homepage": "https://github.com/fabiocaccamo/django-colorfield",
"Issues": "https://github.com/fabiocaccamo/django-colorfield/issues",
"Twitter": "https://twitter.com/fabiocaccamo"
},
"split_keywords": [
"django",
"colorfield",
"colorpicker",
"color",
"field",
"picker",
"chooser",
"admin",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "288206d2517024afa2355a5aefed9c1ef006308f7d655f250cf1c552ff24ced4",
"md5": "c8e9970e2115e55907a8293b32c2347d",
"sha256": "460f40e6123b6ae0fb51a4eb86fc258fcdc0ea28f75102b685e8209b1eae9ec3"
},
"downloads": -1,
"filename": "django_colorfield-0.11.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c8e9970e2115e55907a8293b32c2347d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 53171,
"upload_time": "2023-12-05T22:44:05",
"upload_time_iso_8601": "2023-12-05T22:44:05.719780Z",
"url": "https://files.pythonhosted.org/packages/28/82/06d2517024afa2355a5aefed9c1ef006308f7d655f250cf1c552ff24ced4/django_colorfield-0.11.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "18c475a831118a0d213a7646b72af8cef264e43116c84083a0e24d2cdebc6102",
"md5": "b4607bae4cc01ca1a2ca743ff0e7b3cb",
"sha256": "05c38c8eb2a94938b810a19b2011846391a4ce71d1c92e88a35974fbcc8fc62e"
},
"downloads": -1,
"filename": "django-colorfield-0.11.0.tar.gz",
"has_sig": false,
"md5_digest": "b4607bae4cc01ca1a2ca743ff0e7b3cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 55337,
"upload_time": "2023-12-05T22:44:07",
"upload_time_iso_8601": "2023-12-05T22:44:07.190773Z",
"url": "https://files.pythonhosted.org/packages/18/c4/75a831118a0d213a7646b72af8cef264e43116c84083a0e24d2cdebc6102/django-colorfield-0.11.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-05 22:44:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fabiocaccamo",
"github_project": "django-colorfield#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "django-colorfield"
}