5👍
✅
Yes, according to the documentation you can get the human readable value like this:
context.get_priority_display()
-2👍
The value on the left is the value Django uses to store in the db. It doesn’t have to be an integer. Just make both values identical:
PRIORITY = (
('high', _(u'High')),
('Medium', _(u'Medium')),
('Low', _(u'Low')),
)
- [Django]-Django Rest Framework filter a calculated SerializerMethodField() in ViewSet using filterset_fields
- [Django]-'NoneType' object has no attribute 'endswith', django , python
- [Django]-Django bulk remove and add many to many relationships
Source:stackexchange.com