Package: django-country-kit
Django Country KitDjango Country Kit is a Django app that provides country-related functionality, including a custom model field for storing country codes, a form widget for selecting countries, and associated tests.FeaturesCountry Model Field:Easily store and retrieve country codes in your Django models.Country Widget:A form widget for rendering a dropdown list of countries in your Django forms.InstallationInstall Django Country Kit using pip:pipinstalldjango-country-kitAdd'django_country_kit'to yourINSTALLED_APPSin your Django project's settings:INSTALLED_APPS=[# ...'django_country_kit',# ...]Run collectstatic:pythonmanage.pycollectstaticUsageCountry Model FieldIn your models, use theCountryFieldto store country codes:fromdjango.dbimportmodelsfromdjango_country_kit.fieldsimportCountryFieldclassYourModel(models.Model):country=CountryField()For multiple selections:fromdjango.dbimportmodelsfromdjango_country_kit.fieldsimportCountryFieldclassYourModel(models.Model):countries=CountryField(multiple=True)Country WidgetIn your forms, use theCountryWidgetto render a dropdown list of countries:fromdjangoimportformsfromdjango_country_kit.widgetsimportCountryWidgetclassYourForm(forms.Form):country=forms.CharField(widget=CountryWidget())For multiple selections:fromdjangoimportformsfromdjango_country_kit.widgetsimportMultipleCountryWidgetclassYourForm(forms.Form):countries=forms.CharField(widget=MultipleCountryWidget())Country ClassTheCountryclass represents a country and provides properties for accessing its name and alpha3 code. This class is part of the Django Country Kit and offers convenient functionality for handling country-related data.UsageYou can create an instance of theCountryclass to retrieve information about a specific country. Here's how you can use it:fromdjango_country_kit.baseimportCountry# Create a Country instance with a specific country codecountry=Country(code='US')# Retrieve the name of the countrycountry_name=country.name# Returns 'United States'# Retrieve the alpha3 code of the countrycountry_alpha3=country.alpha3# Returns 'USA'Custom settingsDjango Country Kit provides custom settings for further customization of country data:OVERRIDE_COUNTRIES: Allows users to override specific countries with custom data.EXCLUDE_COUNTRIES: Allows users to exclude specific countries from the available choices.INCLUDE_COUNTRIES: Allows users to include specific countries in the available choices.You can customize these settings in your Django project's settings file to tailor the country data according to your needs.We appreciate your feedback and contributions to improving Django Country Kit!DevelopmentIf you want to contribute to Django Country Kit, follow these steps to set up your development environment:Install pipenv if you haven't already:pipinstallpipenvClone the repository:gitclonehttps://github.com/your_username/django-country-kit.gitNavigate to the project directory:cddjango-country-kitInstall development dependencies:,pipenvinstall--devActivate the virtual environment:pipenvshellRun migrations:pythonmanage.pymigrateRun collectstatic:pythonmanage.pycollectstaticStart the development server:pythonmanage.pyrunserver