Open
Conversation
…format, and official language metadata to CountryField
…_symbol, calling_code, utc_offset, capital_city, continent, date_format, official_languages and timezones
Author
|
@SmileyChris some of the changes to the code style (imports) was due to my use of python black to format the source files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rich Country Metadata
Summary
This PR introduces country metadata (currency_name, currency_symbol, calling_code, capital_city, utc_offset, continent, date_format, official_language and timezones) to the
Countryobject and enhances Django Rest Framework serialization to easily expose this data to frontends.Features
Rich Metadata on
CountryObjects:Access essential country details directly:
currency_name¤cy_symbol(e.g., "British pound", "£")calling_code(e.g., "+44")capital_city(e.g., "London")utc_offset,continent,date_format,official_language,timezones.Optimized:
Metadata is sourced from a local YAML file and cached in memory.
DRF Integration:
Added the fields to serializers.
Usage
Python / Django Models
Sample Output
Here is the data available for the
Country('NZ')object:currency_name'New Zealand dollar'currency_symbol'$'calling_code'+64'utc_offset'-11:00'capital_city'Wellington'continent'Oceania'date_format'DD/MM/YYYY'official_language['English', 'Māori', 'New Zealand Sign Language']timezones['UTC−11:00', 'UTC−10:00', 'UTC+12:00', 'UTC+12:45', 'UTC+13:00']