Last active
October 26, 2016 04:51
-
-
Save hirokiky/a73535e37e555bed3301bcbe938f38cb to your computer and use it in GitHub Desktop.
A Base Enum class which can be used for Django's choices field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChoicesEnum(Enum): | |
def __str__(self): | |
return self.value | |
@classmethod | |
def choices(cls): | |
return tuple( | |
(item.value, item.name.replace('_', ' ').title()) for item in cls | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment