Django REST EnumField
EnumField that uses python enums for Django REST Framework
Installation
pip install django-rest-enumfield
Usage
Use it as if its a ChoiceField:
import enum
from rest_enumfield import EnumField
class Color(enum.Enum):
RED = "red"
GREEN = "green"
BLUE = "blue"
class SomeSerializer(Serializer):
color = EnumField(choices=Color)
Additionally you can override choice name and value generation by providing to_choice or to_repr arguments:
class SomeSerializer(Serializer):
color = EnumField(choices=Color, to_choice=lambda x: (x.value, x.name), to_repr=lambda x: x.value)
This will cause the enum’s value instead of the name to be represented.
Thats it.
Metadata
Release files for django-rest-enumfield 0.2.0
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 | Actions |
|---|---|---|---|---|
| django-rest-enumfield-0.2.0.tar.gz | 3.0 kB | Without provenance | Details for django-rest-enumfield-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_rest_enumfield-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_rest_enumfield-0.2.0-py2.py3-none-any.whl |
Total release size: 7.0 kB
Release files / django-rest-enumfield-0.2.0.tar.gz
| Download URL | django-rest-enumfield-0.2.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e3c1121e136dd7163c92737dcd67e0c6b78e78793b740b0811753343c7da8fe
|
|
BLAKE2b-256 checksum How to use checksums |
7dffab47c411c40253fd3fd66ebc04f2bd4e9034559f19d28aabef49f0f00689
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4
|
Release files / django_rest_enumfield-0.2.0-py2.py3-none-any.whl
| Download URL | django_rest_enumfield-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
80792326d5d8fad8a66729e9404a4078fe16f7eb8b2a910b37157d96df415611
|
|
BLAKE2b-256 checksum How to use checksums |
9c27e7b1b166a3e36983f73b49bfcb974e29f46807c3ebc1a2c5fc0ec0e8a8d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4
|
Security for django-rest-enumfield 0.2.0
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.