Provides a colorpicker field for Django
Project description
django-spectrum
Provides a colorpicker field for Django
Compatibility
django
>= 1.11python
>= 3.5
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.opaque)
False
>>> print(c.hex())
"#FFDA00"
>>> print(c.hexa())
"#FFDA0080"
>>> print(c.rgba())
"rgba(255, 218, 0, 0.5)"
>>> print(c.opacity())
0.5
>>> print(c.hsla())
"hsla(51, 100.0%, 50.0%, 0.5)"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-spectrum-0.2.1.tar.gz
(32.9 kB
view hashes)
Built Distribution
Close
Hashes for django_spectrum-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93b0988499d7eb106414b351c7365c5c9042eb7ed8fd51839b0ef511af8ed356 |
|
MD5 | 5e79b9e837ddcea3d6a39e42d9638221 |
|
BLAKE2b-256 | 6711468bf0cd6c9f46fc89ebb51682909862e1011262df76a7c0e1687e132d41 |