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
- Python 3.X
- Postgresql database in django.
Installation
pip install django-pg-colorfield
Quick start
- Add colorfield to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'colorfield',
]
- 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()
- 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_pg_colorfield-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95bfa05ff31f23e21d5fbc3260433a6794808c10dbe680e722e5c8cad2721e9f |
|
MD5 | 6dc73f5e8fce8d21faab3adc42b5bbb3 |
|
BLAKE2b-256 | 89320624115490f445e1b403f8155f9924b8033c529b75ee14d0a6b72282b073 |