Re: [DRF] Serializing a field of type choice

2021-06-10 Thread ezequia...@gmail.com
I solved the problem using a SerializerMethodField. Thank you anyone. On Thursday, June 10, 2021 at 11:47:37 AM UTC-3 nik...@exiverlabs.co.in wrote: > You must me getting the keys of your choices rather than your choice text > , you can override the field with serializer method field and

Re: [DRF] Serializing a field of type choice

2021-06-10 Thread Nikeet NA
You must me getting the keys of your choices rather than your choice text , you can override the field with serializer method field and return your text according to your choice key. On Thu, 10 Jun 2021 at 09:57, Lalit Suthar wrote: > can I see that model field, I don't think any extra

Re: [DRF] Serializing a field of type choice

2021-06-10 Thread ezequia...@gmail.com
*Here is my attempt:* question_type = ( (1, 'Discussion'), (2, 'Multiple Choice'), (3, 'Writing'), (4, 'Objective'), (5, 'True or False'), (6, 'Practice'), ) *model.py* class Question(models.Model): de_description = models.TextField(max_length=255)

Re: [DRF] Serializing a field of type choice

2021-06-09 Thread Lalit Suthar
can I see that model field, I don't think any extra configuration is required for it On Thu, 10 Jun 2021 at 04:44, ezequia...@gmail.com wrote: > Hey guys > > Could you help me with a Django Rest Framework question? > > I have a field in my model that has possible input values, so I'm using >

[DRF] Serializing a field of type choice

2021-06-09 Thread ezequia...@gmail.com
Hey guys Could you help me with a Django Rest Framework question? I have a field in my model that has possible input values, so I'm using the *choices=* attribute in my model. I'm having difficulty serializing the return of this data in drf. Could someone give me a hint on how best to