Skip to main content

Django field that set/get django's new TextChoices enum.

Project description

django-choices-field

build status coverage PyPI version python version django version

Django field that set/get django's new TextChoices enum.

Install

pip install django-choices-field

Usage

from django.db import models
from django_choices_field import ChoicesField


class MyModel(models.Model):
    class MyEnum(models.TextChoices):
        FOO = "foo", "Foo Description"
        BAR = "bar", "Bar Description"

    c_field = ChoicesField(
        choices_enum=MyEnum,
        default=MyEnum.FOO,
    )


obj = MyModel()
obj.c_field  # MyModel.MyEnum.FOO
isinstance(obj.c_field, MyModel.MyEnum) # True

License

This project is licensed under MIT licence (see LICENSE for more info)

Contributing

Make sure to have poetry installed.

Install dependencies with:

poetry install

Run the testsuite with:

poetry run pytest

Feel free to fork the project and send me pull requests with new features, corrections and translations. I'll gladly merge them and release new versions ASAP.

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-choices-field-1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

django_choices_field-1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file django-choices-field-1.0.tar.gz.

File metadata

  • Download URL: django-choices-field-1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.2 Linux/5.8.0-1036-azure

File hashes

Hashes for django-choices-field-1.0.tar.gz
Algorithm Hash digest
SHA256 282ed6b020d9f4297cc29860751ca8849385703515af8523c89f2291bd273665
MD5 1ac6d2cf8ce44e103ce78a000a69f3d2
BLAKE2b-256 96135d426485285dae07306e20ae998b69f158bec19c9b27b908728dadaac1e9

See more details on using hashes here.

File details

Details for the file django_choices_field-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_choices_field-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5111bf025256b15be9eb05f45d85e93086a66d6e2a4efd7b06bd2737ef392d3d
MD5 9c3bdeda1e4138e07be0ece72b682d3d
BLAKE2b-256 587a90e8d6adc8043d1c586c0eb49e96661611647e8855b60cc1367a2dcd9b15

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