I’ve got a model which has nearly ten fields and one of them is Boolean field.
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
nick_name = models.CharField(max_length=30)
be_anonymous = models.BooleanField(default=False)
character = models.ChoiceField(…)
I’ve got a ViewSet and serializers for this model and there’s an endpoint to get list of all Persons.
For some persons, be_anonymous is set to True and for those persons, I want to hide first_name and last_name from API response and instead include nick_name.
How can I hide/show those fields based on that Boolean field?
Any advice will be appreciated