Skip to main content

Provides a colorpicker field for Django

Project description

django-spectrum

Provides a colorpicker field for Django

image

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.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)

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.5.3.tar.gz (122.2 kB view details)

Uploaded Source

Built Distribution

django_spectrum-0.5.3-py2.py3-none-any.whl (124.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-spectrum-0.5.3.tar.gz.

File metadata

  • Download URL: django-spectrum-0.5.3.tar.gz
  • Upload date:
  • Size: 122.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for django-spectrum-0.5.3.tar.gz
Algorithm Hash digest
SHA256 52fd2f3d7e89a84e6904914fdb76539fd401aa0ff1f934a4d64065835a0324e2
MD5 de404c4686aea560008bd3011b6c3358
BLAKE2b-256 951d7deeb5f2f106bc1b2008ba4ec1028f5338ffda1cd266572f46873644f75e

See more details on using hashes here.

File details

Details for the file django_spectrum-0.5.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_spectrum-0.5.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5ebb24295dbff26c7560fed64ea5ef359733ebb3d8d90b6da0b1ad30741b4ad4
MD5 77bcadaec83b828f02d2180c11e16fd7
BLAKE2b-256 b552d9f999a39ee0010d1257e1bc1c8b1460560e4b2a7f9a3dc30402fb568987

See more details on using hashes here.

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