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

Uploaded Source

Built Distribution

django_choices_field-0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-choices-field-0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.2 Linux/5.10.0-8-amd64

File hashes

Hashes for django-choices-field-0.1.tar.gz
Algorithm Hash digest
SHA256 eecfb4566f7462ad070003f27659e4a7f6f11a75f199ff68299e27fb3bb3bb14
MD5 f73d2f3ae49fcedd42a0a849a57a4a91
BLAKE2b-256 bf68bf0aaec6c2805e53cdb11cde32fa8d91311afdcc254d4be67f201dae70ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_choices_field-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 748c772198cd64b26f5939683881f5b3720091d5db8a5542864b53923cbd173c
MD5 05d936a3d2f2a668272d63ca6c59eadc
BLAKE2b-256 5d16910ba7d4683f4d8d4c73e24f825c715cb2a3620296d46d96113bbcda23b5

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