Skip to main content

https://github.com/serioeseGmbH/serious-django-enums

serious-django-enums defines an Enum-like class, AutoEnum, that intends to bring together the pattern to define choice fields that Django uses, and intuitive usage of Enums like most people know them.

Consider the example where you’ve defined your choices on a ChoiceField, e.g.:

class SomeForm(forms.Form):
    ...
    STATE_CHOICES = (
        ("ACTIVE", "active"),
        ("ENDED", "ended"),
    )
    field = forms.ChoiceField(choices=STATE_CHOICES, default="ACTIVE")

What this package gives you is wrapping this in a class and having it accessible as class attributes:

class States(AutoEnum):
    choices = (
        ("ACTIVE", "active"),
        ("ENDED", "ended"),
    )

class SomeForm(forms.Form):
    field = forms.ChoiceField(choices=States.choices, default=States.ACTIVE)

which has the advantage of being import-able from different parts of your code and not directly tied to the form, and also gives you nice-looking property access instead of dictionary-like key access.

The definition is currently extremely basic, but has suited our needs well.

Quick start

  1. Install the package with pip:

    pip install serious-django-enums
  2. Import serious_django_enums.AutoEnum and subclass it, defining a choices property on the class.

  3. Use the auto-defined member properties of your AutoEnum-subclasses wherever you need them.

Metadata

Release files for serious-django-enums 0.1

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

Source distribution (sdist)

Source distribution for serious-django-enums 0.1
File Size Uploaded Provenance Actions
serious-django-enums-0.1.tar.gz 3.2 kB Without provenance Details for serious-django-enums-0.1.tar.gz

Release files / serious-django-enums-0.1.tar.gz

Download URL serious-django-enums-0.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
16c19645bd288b5bf4571dfb00abab26959c251b386f74abf2b2f8b6b3dc536f
BLAKE2b-256 checksum
How to use checksums
0f286c241b65511b62e750a4d1b3614daea82bab210b1b90a058dac11bb83179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Security for serious-django-enums 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

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