django-country-kit


Namedjango-country-kit JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttp://github.com/pescheckit/django-country-kit
SummaryCountries for django
upload_time2024-01-31 10:34:10
maintainer
docs_urlNone
authorPescheck IT
requires_python
licenseMIT
keywords django country
VCS
bugtrack_url
requirements asgiref Django sqlparse
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": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,country",
    "author": "Pescheck IT",
    "author_email": "devops@pescheck.io",
    "download_url": "https://files.pythonhosted.org/packages/3e/84/c7665582a72ec171000f51c6bc25c554f0db7e050e6b4c051e5245fa2814/django-country-kit-0.0.2.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.2",
    "project_urls": {
        "Homepage": "http://github.com/pescheckit/django-country-kit"
    },
    "split_keywords": [
        "django",
        "country"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a12b01d27f8e0fb1adcbe23954d6b31285d2f9b052df1cb79a1f7db34a33ad5",
                "md5": "581a60b082b7849cb0dc9f2fe6cff4aa",
                "sha256": "1e1c68d9b9c8a838383a4209a5f3f25462215a19e7676044b1f99603ae9db688"
            },
            "downloads": -1,
            "filename": "django_country_kit-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "581a60b082b7849cb0dc9f2fe6cff4aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14106,
            "upload_time": "2024-01-31T10:34:08",
            "upload_time_iso_8601": "2024-01-31T10:34:08.481293Z",
            "url": "https://files.pythonhosted.org/packages/0a/12/b01d27f8e0fb1adcbe23954d6b31285d2f9b052df1cb79a1f7db34a33ad5/django_country_kit-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e84c7665582a72ec171000f51c6bc25c554f0db7e050e6b4c051e5245fa2814",
                "md5": "919b71a4014c78e75e42c96b4e4e1b35",
                "sha256": "4f522afe9fd2c701c39a16deabb110d111b7397c0e333afff77398ccfa0e0d4b"
            },
            "downloads": -1,
            "filename": "django-country-kit-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "919b71a4014c78e75e42c96b4e4e1b35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13678,
            "upload_time": "2024-01-31T10:34:10",
            "upload_time_iso_8601": "2024-01-31T10:34:10.557942Z",
            "url": "https://files.pythonhosted.org/packages/3e/84/c7665582a72ec171000f51c6bc25c554f0db7e050e6b4c051e5245fa2814/django-country-kit-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-31 10:34:10",
    "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": [
        {
            "name": "asgiref",
            "specs": [
                [
                    "==",
                    "3.7.2"
                ]
            ]
        },
        {
            "name": "Django",
            "specs": [
                [
                    "==",
                    "5.0.1"
                ]
            ]
        },
        {
            "name": "sqlparse",
            "specs": [
                [
                    "==",
                    "0.4.4"
                ]
            ]
        }
    ],
    "lcname": "django-country-kit"
}
        
Elapsed time: 0.30223s