A Django 1.7+ model field for use with Python 3 enums.
Works with any enum whose values are integers. Subclasses the IntegerField to store the enum as integers in the database.
When creating/loading fixtures, values are serialized to dotted names, like “AnimalType.Cat” for the example below.
A decorator is needed on Python enums in order to make them work with Django migrations, which require a deconstruct() method on the enum members.
Installation:
pip install enum3field
Example:
import enum from enum3field import EnumField, django_enum @django_enum class AnimalType(enum.Enum): Cat = 1 Dog = 2 Turtle = 3 class Animal(models.Model): animalType = EnumField(AnimalType)
Requires Python 3. Not tested with Django versions prior to 1.7 but might work.
Metadata
Release files for enum3field 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| enum3field-0.1.1.tar.gz | 2.8 kB | Without provenance | Details |
Release files / enum3field-0.1.1.tar.gz
| Download URL | enum3field-0.1.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea6196d88bdd75313f38dbbdbc8acd0794c555f4f8ff46d96f407dcc082d6ea5
|
|
BLAKE2b-256 checksum How to use checksums |
028409ce87190cf19253c6da44837903eca05d3a2c48c3bd07b3975dfee1b321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for enum3field 0.1.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.