Skip to content

Country Serializer Documentation

This section outlines the CountrySerializer, which is used in the API to handle the serialization of country data. This serializer transforms data between Django models and JSON format, facilitating API requests and responses.


Serializers

  1. Country Serializer: CountrySerializer

1. Country Serializer

Serializer Overview

CountrySerializer is used to serialize country data. It includes the country's unique identifier, name, ISO code, and a list of associated states.

Fields

Field Type Description
id integer The unique identifier for the country.
country_name string The name of the country.
iso_code string The ISO code of the country.
country_states array A list of states associated with the country.

Example Response

Reponse

{
  "id": 1,
  "country_name": "United States",
  "iso_code": "US",
  "country_states": [
    {
      "id": 1,
      "name": "California"
    },
    {
      "id": 2,
      "name": "Texas"
    }
  ]
}