django-country-kit


Namedjango-country-kit JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttp://github.com/pescheckit/django-country-kit
SummaryCountries for django
upload_time2024-10-21 15:30:54
maintainerNone
docs_urlNone
authorPescheck IT
requires_pythonNone
licenseMIT
keywords django country
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

## Installation

1. Install Django Country Kit using pip:

    ```bash
    pip install django-country-kit
    ```

2. Add `'django_country_kit'` to your `INSTALLED_APPS` in your Django project's settings:

    ```python
    INSTALLED_APPS = [
        # ...
        'django_country_kit',
        # ...
    ]
    ```

3. Run collectstatic:

    ```bash
    python manage.py collectstatic
    ```


## Usage

### Country Model Field

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

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

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

For multiple selections:
```python
from django.db import models
from django_country_kit.fields import CountryField

class YourModel(models.Model):
    countries = CountryField(multiple=True)
```


### Country Widget

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

```python
from django import forms
from django_country_kit.widgets import CountryWidget

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

For multiple selections:
```python
from django import forms
from django_country_kit.widgets import MultipleCountryWidget

class YourForm(forms.Form):
    countries = forms.CharField(widget=MultipleCountryWidget())
```

## Country Class

The `Country` class 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.

### Usage

You can create an instance of the `Country` class to retrieve information about a specific country. Here's how you can use it:

```python
from django_country_kit.base import Country

# Create a Country instance with a specific country code
country = Country(code='US')

# Retrieve the name of the country
country_name = country.name  # Returns 'United States'

# Retrieve the alpha3 code of the country
country_alpha3 = country.alpha3  # Returns 'USA'
```

## 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.
- `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!


## Development

If you want to contribute to Django Country Kit, follow these steps to set up your development environment:

1. Install pipenv if you haven't already:

    ```bash 
    pip install pipenv
    ```
2. Clone the repository:

    ```bash 
    git clone https://github.com/your_username/django-country-kit.git
    ```
3. Navigate to the project directory:

    ```bash 
    cd django-country-kit
    ```
4. Install development dependencies:,

    ```bash 
    pipenv install --dev
    ```
5. Activate the virtual environment:

    ```bash 
    pipenv shell
    ```
6. Run migrations:

    ```bash 
    python manage.py migrate
    ```
7. Run collectstatic:

    ```bash 
    python manage.py collectstatic
    ```
8. Start the development server:

    ```bash 
    python manage.py runserver
    ```

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/pescheckit/django-country-kit",
    "name": "django-country-kit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django, country",
    "author": "Pescheck IT",
    "author_email": "devops@pescheck.io",
    "download_url": "https://files.pythonhosted.org/packages/4c/76/897944c27f7951547dc7a4a5239f2607c22e7829a361f07caa2de6314ed8/django-country-kit-0.0.4.tar.gz",
    "platform": null,
    "description": "# Django Country Kit\n\nDjango 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.\n\n## Features\n\n- **Country Model Field:** Easily store and retrieve country codes in your Django models.\n- **Country Widget:** A form widget for rendering a dropdown list of countries in your Django forms.\n\n## Installation\n\n1. Install Django Country Kit using pip:\n\n    ```bash\n    pip install django-country-kit\n    ```\n\n2. Add `'django_country_kit'` to your `INSTALLED_APPS` in your Django project's settings:\n\n    ```python\n    INSTALLED_APPS = [\n        # ...\n        'django_country_kit',\n        # ...\n    ]\n    ```\n\n3. Run collectstatic:\n\n    ```bash\n    python manage.py collectstatic\n    ```\n\n\n## Usage\n\n### Country Model Field\n\nIn your models, use the `CountryField` to store country codes:\n\n```python\nfrom django.db import models\nfrom django_country_kit.fields import CountryField\n\nclass YourModel(models.Model):\n    country = CountryField()\n```\n\nFor multiple selections:\n```python\nfrom django.db import models\nfrom django_country_kit.fields import CountryField\n\nclass YourModel(models.Model):\n    countries = CountryField(multiple=True)\n```\n\n\n### Country Widget\n\nIn your forms, use the `CountryWidget` to render a dropdown list of countries:\n\n```python\nfrom django import forms\nfrom django_country_kit.widgets import CountryWidget\n\nclass YourForm(forms.Form):\n    country = forms.CharField(widget=CountryWidget())\n```\n\nFor multiple selections:\n```python\nfrom django import forms\nfrom django_country_kit.widgets import MultipleCountryWidget\n\nclass YourForm(forms.Form):\n    countries = forms.CharField(widget=MultipleCountryWidget())\n```\n\n## Country Class\n\nThe `Country` class 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.\n\n### Usage\n\nYou can create an instance of the `Country` class to retrieve information about a specific country. Here's how you can use it:\n\n```python\nfrom django_country_kit.base import Country\n\n# Create a Country instance with a specific country code\ncountry = Country(code='US')\n\n# Retrieve the name of the country\ncountry_name = country.name  # Returns 'United States'\n\n# Retrieve the alpha3 code of the country\ncountry_alpha3 = country.alpha3  # Returns 'USA'\n```\n\n## Custom settings\n\nDjango Country Kit provides custom settings for further customization of country data:\n\n- `OVERRIDE_COUNTRIES`: Allows users to override specific countries with custom data.\n- `EXCLUDE_COUNTRIES`: Allows users to exclude specific countries from the available choices.\n- `INCLUDE_COUNTRIES`: Allows users to include specific countries in the available choices.\n\nYou can customize these settings in your Django project's settings file to tailor the country data according to your needs.\n\nWe appreciate your feedback and contributions to improving Django Country Kit!\n\n\n## Development\n\nIf you want to contribute to Django Country Kit, follow these steps to set up your development environment:\n\n1. Install pipenv if you haven't already:\n\n    ```bash \n    pip install pipenv\n    ```\n2. Clone the repository:\n\n    ```bash \n    git clone https://github.com/your_username/django-country-kit.git\n    ```\n3. Navigate to the project directory:\n\n    ```bash \n    cd django-country-kit\n    ```\n4. Install development dependencies:,\n\n    ```bash \n    pipenv install --dev\n    ```\n5. Activate the virtual environment:\n\n    ```bash \n    pipenv shell\n    ```\n6. Run migrations:\n\n    ```bash \n    python manage.py migrate\n    ```\n7. Run collectstatic:\n\n    ```bash \n    python manage.py collectstatic\n    ```\n8. Start the development server:\n\n    ```bash \n    python manage.py runserver\n    ```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Countries for django",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "http://github.com/pescheckit/django-country-kit"
    },
    "split_keywords": [
        "django",
        " country"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "775dcc8869d54aedd54241338cc5eb71eb9a0fef60531b1ff98e7059a24a32b2",
                "md5": "0d9095bffd2e082e30357f9b3edc2872",
                "sha256": "de8c9d77c7a40f3cedac1d0907a0a50d7ca5e8d268abd840ed08737edc796a18"
            },
            "downloads": -1,
            "filename": "django_country_kit-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d9095bffd2e082e30357f9b3edc2872",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14485,
            "upload_time": "2024-10-21T15:30:52",
            "upload_time_iso_8601": "2024-10-21T15:30:52.691192Z",
            "url": "https://files.pythonhosted.org/packages/77/5d/cc8869d54aedd54241338cc5eb71eb9a0fef60531b1ff98e7059a24a32b2/django_country_kit-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c76897944c27f7951547dc7a4a5239f2607c22e7829a361f07caa2de6314ed8",
                "md5": "b5ba636bb9fb5a8bc5b5c71a11ed0b12",
                "sha256": "3a7e6ec76402c94f4d0c6371747ad50508a6095fa74b886cf78f5e0abf9cf46b"
            },
            "downloads": -1,
            "filename": "django-country-kit-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b5ba636bb9fb5a8bc5b5c71a11ed0b12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14066,
            "upload_time": "2024-10-21T15:30:54",
            "upload_time_iso_8601": "2024-10-21T15:30:54.193649Z",
            "url": "https://files.pythonhosted.org/packages/4c/76/897944c27f7951547dc7a4a5239f2607c22e7829a361f07caa2de6314ed8/django-country-kit-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 15:30:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pescheckit",
    "github_project": "django-country-kit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "django-country-kit"
}
        
Elapsed time: 9.77423s