Skip to main content

Countries for django

Project description

Django Country Kit

Django 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.

Features

  • Country 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.
  • Tested: Comprehensive tests for ensuring the functionality of the provided components.

Installation

  1. Install Django Country Kit using pip:

    pip install django-country-kit
    
  2. Add 'django_country_kit' to your INSTALLED_APPS in your Django project's settings:

    INSTALLED_APPS = [
        # ...
        'django_country_kit',
        # ...
    ]
    
  3. Run migrations to create the necessary database tables:

    python manage.py migrate
    
  4. Run collectstatic:

    python manage.py collectstatic
    

Usage

Country Model Field

In your models, use the CountryField to store country codes:

from django.db import models
from django_country_kit.fields import CountryField

class YourModel(models.Model):
    country = CountryField()

Country Widget

In your forms, use the CountryWidget to render a dropdown list of countries:

from django import forms
from django_country_kit.widgets import CountryWidget

class YourForm(forms.Form):
    country = forms.CharField(widget=CountryWidget())

Custom settings

Django 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.

You can customize these settings in your Django project's settings file to tailor the country data according to your needs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-country-kit-0.0.1.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distribution

django_country_kit-0.0.1-py3-none-any.whl (13.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page