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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_spectrum-0.5.2-py2.py3-none-any.whl (36.9 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for django-spectrum-0.5.2.tar.gz
Algorithm Hash digest
SHA256 85de267062cc437254d50c0953cc30ce361f8ebc1bc3e0868fc0f6e616ba5bb8
MD5 2a3eb3194e7f4860de21630e4903b1ee
BLAKE2b-256 a57ca854f53ba176a2b722eeb0713dfe1e197035fc5cd80a3e97a7bb9110c9ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_spectrum-0.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5bab055c9850fb92ab3e60cf12b481906200fb98930257db582b3f17fce03260
MD5 8e40d88bdc4ab9fbc4791e6b3936f296
BLAKE2b-256 fd17abe4fee5ecf44a88fdf1fd937662b962a2b12d09ad955852c5214846b7dd

See more details on using hashes here.

Supported by

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