
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.