Skip to main content
https://circleci.com/gh/olist/easy-choices.svg?style=shield

It’s a library deeply inspired by Choices from django-model-utils. However, sometimes we just need to use Choices rather than all the features provided by django-model-utils.

Requirements

  • Python >= 3.5

Usage

The easy-choices package is hosted on our PyPI repository.

You can install the latest version of easy-choices using pip:

$ pip install easy-choices

And use easy-choices as it’s demonstrated below:

from django.db import models
from easy_choices import Choices

status_choices = Choices(
    ("sent", "Sent"),
    ("delivered", "Delivered"),
)

class Product(models.Model)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    status = models.CharField(max_length=10, choices=status_choices.to_django_choices())

    @property
    def is_delivered(self):
        # You can use status_choices as a Enum
        return self.status == status_choices.delivered

Release files for easy-choices 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-choices 1.0.0
File Size Uploaded
easy-choices-1.0.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-choices 1.0.0
File Interpreter ABI Platform
easy_choices-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / easy-choices-1.0.0.tar.gz

Download URL easy-choices-1.0.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
37c3fe5328f73c20cf7fad8c6e258c8aea513b756c8048949cffc63197d03d03
BLAKE2b-256 checksum
How to use checksums
c5c6ec233c899ecaee2c06d0bc8acb5f3d4321f9a59ced26e93021351a926cbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / easy_choices-1.0.0-py3-none-any.whl

Download URL easy_choices-1.0.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a4874719ad57b0f6762224413a873100434c31fc43f9759738c3a8b440a27ba
BLAKE2b-256 checksum
How to use checksums
90e9211f2ac5ed3a2789aac7e5a197e77423e54f1cef3470747908e4e429d551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page