
from rest_framework import serializers

from message.models import Message


class MessageSerializer(serializers.ModelSerializer):
    class Meta:
        model = Message


class MapMessageSerializer(serializers.ModelSerializer):
    lat = serializers.Field(source='location.latitude')
    lon = serializers.Field(source='location.longitude')

    class Meta:
        model = Message
        fields = ['id', 'title', 'lat', 'lon',]


from rest_framework import serializers

from message.models import Message


class MessageSerializer(serializers.ModelSerializer):
    class Meta:
        model = Message


class MapMessageSerializer(serializers.ModelSerializer):
    lat = serializers.Field(source='location.latitude')
    lon = serializers.Field(source='location.longitude')

    class Meta:
        model = Message
        fields = ['id', 'title', 'lat', 'lon', 'messageType']

Add message type field for api serializer
Add message type field for api serializer

  
  from rest_framework import serializers
  
  from message.models import Message
  
  
  class MessageSerializer(serializers.ModelSerializer):
      class Meta:
          model = Message
  
  
  class MapMessageSerializer(serializers.ModelSerializer):
      lat = serializers.Field(source='location.latitude')
      lon = serializers.Field(source='location.longitude')
  
      class Meta:
          model = Message
-         fields = ['id', 'title', 'lat', 'lon',]
+         fields = ['id', 'title', 'lat', 'lon', 'messageType']
  
Add message type field for api serializer
## Code Before:

from rest_framework import serializers

from message.models import Message


class MessageSerializer(serializers.ModelSerializer):
    class Meta:
        model = Message


class MapMessageSerializer(serializers.ModelSerializer):
    lat = serializers.Field(source='location.latitude')
    lon = serializers.Field(source='location.longitude')

    class Meta:
        model = Message
        fields = ['id', 'title', 'lat', 'lon',]

## Instruction:
Add message type field for api serializer
## Code After:

from rest_framework import serializers

from message.models import Message


class MessageSerializer(serializers.ModelSerializer):
    class Meta:
        model = Message


class MapMessageSerializer(serializers.ModelSerializer):
    lat = serializers.Field(source='location.latitude')
    lon = serializers.Field(source='location.longitude')

    class Meta:
        model = Message
        fields = ['id', 'title', 'lat', 'lon', 'messageType']
