Skip to main content

simple color field for your models with a nice color-picker in the admin-interface.

Project description

django-colorfield

simple color field for your models with a nice color-picker in the admin-interface.

django-colorfield-hex django-colorfield-hexa

Installation

  • Run pip install django-colorfield
  • Add colorfield to settings.INSTALLED_APPS
  • Run python manage.py collectstatic
  • Restart your application server

Usage

Settings

This package doesn't need any setting.

Models

Just add color field(s) to your models like this:

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

class MyModel(model.Model):
    color = ColorField(default='#FF0000')

Color Format

ColorField defaults to HEX format but also support HEXA. To set the format:

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

class MyModel(model.Model):
    color = ColorField(format='hexa')

Color Palette

django-colorfield-palette

It is possible to provide a palette to choose from to the widget. It can be done by using the field choices (force to choose from choices) or samples (just like choices, but allows also custom color selection).

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

class MyModel(model.Model):

    COLOR_CHOICES = [
        ("#FFFFFF", "white"),
        ("#000000", "black")
    ]

    # restrictive
    color = ColorField(choices=COLOR_CHOICES)

    # not restrictive
    color = ColorField(samples=COLOR_CHOICES)

Admin

The admin will kindly provide a simple color picker for all color fields. :)

Testing

# create python virtual environment
virtualenv testing_django_colorfield

# activate virtualenv
cd testing_django_colorfield && . bin/activate

# clone repo
git clone https://github.com/fabiocaccamo/django-colorfield.git src && cd src

# install dev requirements
pip install -r requirements.txt

# run tests
tox
# or
python setup.py test
# or
python -m django test --settings "tests.settings"

Credits

Originally developed by Jared Forsyth

License

Released under MIT License.


See also

  • django-admin-interface - the default admin interface made customizable by the admin itself. popup windows replaced by modals. 🧙 ⚡

  • django-extra-settings - config and manage typed extra settings using just the django admin. ⚙️

  • django-maintenance-mode - shows a 503 error page when maintenance-mode is on. 🚧 🛠️

  • django-redirects - redirects with full control. ↪️

  • django-treenode - probably the best abstract model / admin for your tree based stuff. 🌳

  • python-benedict - dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘

  • python-codicefiscale - encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. 🇮🇹 💳

  • python-fontbro - friendly font operations. 🧢

  • python-fsutil - file-system utilities for lazy devs. 🧟‍♂️

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-colorfield-0.5.0.tar.gz (48.6 kB view details)

Uploaded Source

Built Distribution

django_colorfield-0.5.0-py3-none-any.whl (46.9 kB view details)

Uploaded Python 3

File details

Details for the file django-colorfield-0.5.0.tar.gz.

File metadata

  • Download URL: django-colorfield-0.5.0.tar.gz
  • Upload date:
  • Size: 48.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

File hashes

Hashes for django-colorfield-0.5.0.tar.gz
Algorithm Hash digest
SHA256 670ef72ded093360c9781fedd33d9ead267b34481139d4ab240dfacea5cf0abf
MD5 1b0ca3d519255e53fa859d444720574f
BLAKE2b-256 7030f4bedb02aa3813234993136f47effdd96bb14830d88f17250af47cd82735

See more details on using hashes here.

File details

Details for the file django_colorfield-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: django_colorfield-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 46.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

File hashes

Hashes for django_colorfield-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aba49684ba1fce80af15237b49ca4a504e49e525c2897db2cce5705b2fa51f3b
MD5 3b18608e433a78168344411e41fb342a
BLAKE2b-256 45593f853a4e91acc2343bdd3ed246f2924c36e2bc64c10480109782c096e30c

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