Skip to main content

choices.py

choices.py is a wrapper around Django's choices to make them easier to use.

Example

from django.db import models

from choices import Choices


class Student(models.Model):

    class Year(Choices):

        FRESHMAN = 'FR'
        SOPHOMORE = 'SO'
        JUNIOR = 'JR'
        SENIOR = 'SR'

        @property
        def is_upperclass(self):
            return self in (self.JUNIOR, self.SENIOR)

    year_in_school = models.CharField(
        max_length=2, choices=Year.choices(), default=Year.FRESHMAN.value)

    def is_upperclass(self):
        return self.Year(self.year_in_school).is_upperclass

Installing

Install it from PyPI with pip:

pip install choices.py

Requirements:

  • Python 3.4+

Download files

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

Source Distribution

choices.py-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

choices.py-0.1.1-py2.py3-none-any.whl (4.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file choices.py-0.1.1.tar.gz.

File metadata

  • Download URL: choices.py-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for choices.py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b4f2e1538194d1eea770051efe25ed96958cf0846dcc2f839ccc3f1e9911e5a0
MD5 d00fbacf79fb888fbe12faf761ad509c
BLAKE2b-256 7f01c57f94dc1c47a44d38a0522020ae234d3537dfd0bbeb5a3ca0fa9573b632

See more details on using hashes here.

File details

Details for the file choices.py-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for choices.py-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8ec0d5c7b25b7e196def056e3f84bf07feddc93c44f66680fc62eeb78cd12206
MD5 b3e5cfdca24e1bf884cd26f43e471deb
BLAKE2b-256 f7627264d17548b6d783579df177ec7e4abe4507a0296f61106205b5c4140447

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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