Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Django EnumField for Python3 and DRF support

I need EnumField for my Django models. I have tried django-enumfield. But it's not supporting with Django 1.10. I also tried this django-enumfields. But this is not supported with Django REST Framework.

My use case,

# models.py
role = EnumField(UserRoleEnum, default=UserRoleEnum.STUDENT)

# enums.py
class UserRoleEnum(Enum):
  STUDENT = 0
  TEACHER = 1
  ADMIN = 2
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Note: After 3 days. No answer. :(

I used a like that,

enums.py

class MyEnum:
    ADMIN = 0
    NORMAL = 1

USER_ENUM_CHOICES = (
    (0, 'ADMIN'),
    (0, 'NORMAL')
)

models.py

class MyModel(models.Model):
    role = models.CharField(choices=MyEnum.USER_ENUM_CHOICES, max_length=1, ...)

Note: For simple case it's not a bad idea.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!