Skip to main content

Provides a colorpicker field for Django

Project description

django-spectrum

Provides a colorpicker field for Django

django-spectrum

PyPI Build Status

Compatibility

  • python >= 3.6
  • django >= 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.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)"

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-spectrum, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size django_spectrum-0.3.0-py2.py3-none-any.whl (43.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-spectrum-0.3.0.tar.gz (33.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page