
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
django-rest-enumfield
Advanced tools
|Build Status| |PyPI version| |Coveralls Status| |Black|
EnumField that uses python enums for Django REST Framework
::
pip install django-rest-enumfield
Use it as if its a ChoiceField
:
.. code:: python
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:
.. code:: python
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.
.. |Build Status| image:: https://travis-ci.com/shosca/django-rest-enumfield.svg?branch=master :target: https://travis-ci.com/shosca/django-rest-enumfield .. |PyPI version| image:: https://badge.fury.io/py/django-rest-enumfield.svg :target: https://badge.fury.io/py/django-rest-enumfield .. |Coveralls Status| image:: https://coveralls.io/repos/github/shosca/django-rest-enumfield/badge.svg?branch=master :target: https://coveralls.io/github/shosca/django-rest-enumfield?branch=master .. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black
FAQs
EnumField for Django REST Framework
We found that django-rest-enumfield demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.