django-spectrum
Provides a colorpicker field for Django
Compatibility
python>= 3.6django>= 1.11
Quickstart
Install django-spectrum:
pip install django-spectrum
Add it to your INSTALLED_APPS list:
INSTALLED_APPS = (
...
"spectrum",
)
Then add it to your models:
from django.db import models
from spectrum.fields import ColorField
class MyModel(models.Model):
color = ColorField(_("color"), default="#FFFF00")
Color class
The module defines a Color class which is used to represent the ColorField
attribute on the model. The Color class can also be used standalone without
any Django model.
Some examples of funcionality provided by the Color class:
from spectrum.color import Color
c = Color("#FFDA0080")
>>> print(c.red)
255
>>> print(c.alpha)
128
>>> print(c.hex)
#FFDA00
>>> print(c.hexa)
#FFDA0080
>>> print(c.rgb)
rgb(255, 218, 0)
>>> print(c.rgba)
rgba(255, 218, 0, 0.5)
>>> print(c.opacity)
0.5
>>> print(c.as_tuple())
(255, 218, 0, 128)
Metadata
Release files for django-spectrum 0.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-spectrum-0.5.3.tar.gz | 122.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_spectrum-0.5.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 246.6 kB
Release files / django-spectrum-0.5.3.tar.gz
| Download URL | django-spectrum-0.5.3.tar.gz |
|---|---|
| Size | 122.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52fd2f3d7e89a84e6904914fdb76539fd401aa0ff1f934a4d64065835a0324e2
|
|
BLAKE2b-256 checksum How to use checksums |
951d7deeb5f2f106bc1b2008ba4ec1028f5338ffda1cd266572f46873644f75e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / django_spectrum-0.5.3-py2.py3-none-any.whl
| Download URL | django_spectrum-0.5.3-py2.py3-none-any.whl |
|---|---|
| Size | 124.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5ebb24295dbff26c7560fed64ea5ef359733ebb3d8d90b6da0b1ad30741b4ad4
|
|
BLAKE2b-256 checksum How to use checksums |
b552d9f999a39ee0010d1257e1bc1c8b1460560e4b2a7f9a3dc30402fb568987
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|