Skip to main content

A ColorField to save and filter by radius Colors in RGB array in postgresql.

Project description

Django Postgresql ColorField

Inspired by Utsob Roy(Codesign)[https://gitlab.com/codesigntheory/django-postgresql-rgb-colorfield]

Requirements

  1. Python 3.X
  2. Postgresql database in django.

Installation

pip install django-pg-colorfield

Quick start

  1. Add colorfield to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
    ...
    'colorfield',
]
  1. Import and Use ColorField:

To get search features you have to add ColorManager with your model.

from django.db import models
from colorfield_lib.colorfield import fields

class ColorManager(fields.ColorManager, models.Manager):
    # You can put your queryset staff
    pass

class ColorModel(models.Model):
    color = fields.ColorField(null=True, blank=True)

    objects = ColorManager() 
  1. Filtering field.
  • field="color" filed that you want to search.
  • You can also pass as color="[1, 100, 200]" ro color="#0164C8".
  • radius=10 is a margin you consider to search.
queryset = ColorModel.objects.by_radius(
    ...
    field="color",
    color=[1, 100, 200],
    radius=10,
)

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

django-pg-colorfield-1.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

django_pg_colorfield-1.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded 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