Hi Tom,
Noob question here: Does that mean we can't use ModelSerializer if our
model has property access? I mean, will we have to declare the new field in
a model serializer as well?
On Tuesday, June 14, 2016 at 6:30:00 PM UTC+5:30, Tom Christie wrote:
>
> Add the fields to the serializer explicitly.
>
> list_virtual_field = serializers.WhatEverField()
>
>
> On Tuesday, 14 June 2016 13:54:55 UTC+1, Daniel Dubovski wrote:
>>
>> I have the following model:
>> ```
>> class MyModel(models.Model):
>> some_db_field = models.CharField(max_length=100)
>>
>> @propery
>> def list_virtual_field(self):
>> return some_db_field.split('|')
>>
>> @list_virtual_fields(self,value):
>> some_db_field = ','.join(value)
>> ```
>>
>> what i would like it the serializer to auth map this.
>>
>> seems like it it ignore property defined fields, even if i explicitly add
>> them to the Serializer Meta fields,
>>
>> this is because DRF takes the fields from the
>> model._meta.concrete_model._meta.
>>
>> is there anything that can be done? or am i doing this wrong?
>>
>
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.