'rename the get_field_display in django serializer
i am trying to use the get_field_display function in Django in my serializer but I want to rename it to something else(consider it worker_role). what should I do?
class AdminUnsubscriberListSerializer(serializers.ModelSerializer):
worker_role= "get_role_display"
and the model is :
class Worker(models.Model):
ROLE_OPTIONS= [
("AD", _("admin")),
("WO", _("Worker")),]
role= models.CharField(
choices=ROLE_OPTIONS,
null=True,
blank=True,
default=None,
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
