class Meta:
    model = Application
    fields = ('id', 'address1', 'address2', 'address3', 'status')

    def to_representation(self, instance):
        response_dict = dict()
        response_dict['id'] = instance.id
        response_dict['status'] = instance.status
        response_dict['address'] = f"{instance.address1}-
{instance.address2} -{instance.address3} - {instance.address4}"
        return response_dict

I tired that and it's showing me address still in four rows instead of one row.


On Sun, Oct 18, 2020 at 2:01 PM Etémé Tsanga R. <beignethari...@gmail.com>
wrote:

> class Meta:
>   model = Application
>    fields = ('id', 'address1','address2','address3','addres4','status')
>
> def to_representation(self, instance):
>     response_dict = dict()
>     response_dict['id'] = instance.id
>     response_dict['status'] = instance.status
>     response_dict['address'] = f"{instance.address1}- {instance.address2}
>  -{instance.address3}-{instance.address4}"
>     return response_dict
>
> Le dim. 18 oct. 2020 à 09:40, Softtar <softta...@gmail.com> a écrit :
>
>> I want to show full address in one row I have four address fields How i
>> can I do that please.
>> I tried below code it's not working
>>
>> class Meta:
>> model = Application
>> fields = ('id', 'address1 + address2 + address3 + addres4','status')
>>
>> --
>> 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 django-rest-framework+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-rest-framework/93ceeb6a-c7c1-4c7b-834d-81429ef4b0f8n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-rest-framework/93ceeb6a-c7c1-4c7b-834d-81429ef4b0f8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Etémé T.  | Software architecture
> Tel : +237 697-414-835
>         +237 674-507-065
> E-mail :  etem...@yahoo.fr
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django REST framework" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-rest-framework/B71JQxvpRdE/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> django-rest-framework+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-rest-framework/CA%2BBWBj3eHjtt%2BYSMU8DyKF4SBdZ2i0h3KZME1WR_LFTDcQmQeg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-rest-framework/CA%2BBWBj3eHjtt%2BYSMU8DyKF4SBdZ2i0h3KZME1WR_LFTDcQmQeg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/CAKcjTSOm-%3DJvk9pOJonTNnOxC8%3Dxp6m-S_R1sJKPhUtdwJeZnw%40mail.gmail.com.

Reply via email to