Hi, thanks for the answer. This form in the screenshot has not been made by 
me it is the default Browsable Page of rest_framework which maps the 
serializer fields to fill in the value to it, I was thinking of some 
generic way like having a method or option to manipulate how the fields 
value are rendered, to fill in the value!!!
On Tuesday, August 10, 2021 at 4:18:32 PM UTC+5:30 [email protected] 
wrote:

> You will need to loop over the response values using *map* and assign 
> each value to their designated form field.
>
> On Tue, Aug 10, 2021 at 8:12 AM Manish Shah <[email protected]> wrote:
>
>> Greetings everyone,
>>
>> I have these nested serializers, in which the fields are not 
>> appropriately maped to html form fields in default browsable API page of 
>> django rest_framework, I have customized the representation of the 
>> response, and now I want to map those values to the appropriate HTML form 
>> fields
>>
>> Below is my `serializer`
>> ``` python
>> from rest_framework_gis import serializers as gis_serializers
>> from rest_framework import serializers
>>
>> class 
>> NestedtLocationSerializer(gis_serializers.GeoFeatureModelSerializer):
>>     class Meta:
>>         model = Location
>>         geo_field = 'geometry'
>>         fields = (
>>             'type',
>>             'is_mobile',
>>             'name',
>>             'address',
>>             'geometry',
>>         )
>>
>>
>> class NestedFloorplanSerializer(serializers.ModelSerializer):
>>     class Meta:
>>         model = FloorPlan
>>         fields = (
>>             'floor',
>>             'image',
>>         )
>>
>>
>> class DeviceLocationSerializer(serializers.ModelSerializer):
>>     location = NestedtLocationSerializer()
>>     floorplan = NestedFloorplanSerializer(required=False, allow_null=True)
>>
>>     class Meta:
>>         model = DeviceLocation
>>         fields = (
>>             'location',
>>             'floorplan',
>>             'indoor',
>>         )
>> ```
>>
>> with the above serilaizers, I am getting this:-
>> Response:-
>> [image: NbOXd.png]
>>
>>
>> But in the html form fields the values of `is_mobile`, `type`, `name` are 
>> not loading in the html form fields, (probably because the representation 
>> of the data has been customized):-
>>
>> [image: 5AtrZ.png]
>>
>> Is there any way, I can control the default mapping of these values to 
>> appropriate serializer fields to fill the values in the form in the 
>> django-rest-framework browsable page??
>>
>> -- 
>> 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].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-rest-framework/100f6a81-6293-4937-8ffb-73dc81a72401n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-rest-framework/100f6a81-6293-4937-8ffb-73dc81a72401n%40googlegroups.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/8656a230-6221-437b-8cc0-a3bbf9bd8367n%40googlegroups.com.

Reply via email to