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

  • django >= 1.11
  • python >= 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


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)

Uploaded Source

Built Distribution

django_spectrum-0.2.1-py2.py3-none-any.whl (43.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page