Django models for storing and retrieving postal addresses.
Project description
django-address-app
Welcome to Django Address
Quickstart
Install
pip install django-address-app
Add them to your INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_address',
...
]
If you want to use your models and don't want to subclass Abstract models, you must inform django_address about your models in settings.py:
# myproject/settings.py
DJANGO_ADDRESS_COUNTRY_MODEL = "my_app.Country"
DJANGO_ADDRESS_REGION_MODEL = "my_app.Region" # or my_app.State, my_app.Province, etc..
DJANGO_ADDRESS_DISTRICT_MODEL = "my_app.District" # or my_app.County
DJANGO_ADDRESS_LOCALITY_MODEL = "my_app.Locality"
DJANGO_ADDRESS_STREET_MODEL = "my_app.Street"
DJANGO_ADDRESS_ADDRESS_MODEL = "my_app.Address"
If you want change behavior processing AddressField, you can use your Service
# myproject/settings.py
DJANGO_ADDRESS_SERVICE_CLASS = "django_address.service.Address"
Example
from django.db import models
from django_address.fields import AddressField
class Order(models.Model):
"""Order model."""
delivery_address = AddressField(verbose_name="Delivery address")
Setting value:
using dict - required field 'raw' only
obj.address = {
"raw": "Volodymyrska st, 10",
"country": "Ukraine", # can use pk or instance country model
"country_code": "UA",
"region": "Kyiv City", # can use pk or instance Region model
"region_code": "UA-32",
"district": "", # can use pk or instance District model
"district_code": "",
"locality": "Kiev",
"street": "Volodymyrska street", # can use pk or instance Street model
"street_number": "10",
"postal_code": "02000",
"latitude": 50.456302,
"longitude": 30.517044,
"formatted_address": "Khreschatyk St, 15, Kyiv, Ukraine, 02000",
}
or
obj.address = address # pk or Address model instance
Prerequisites
You will need:
python3.8
(seepyproject.toml
for full version)django
with version3.0
Development
When developing locally, we use:
editorconfig
plugin (required)pipenv
(required)pycharm 2017+
orvscode
Alternatives
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-address-app-0.1.13.tar.gz
(11.0 kB
view details)
File details
Details for the file django-address-app-0.1.13.tar.gz
.
File metadata
- Download URL: django-address-app-0.1.13.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f315a6577e57e4a90555483a2713485ab22a094a93b4fbffde8fb3a04f038c7 |
|
MD5 | 77a6814f00323e8f1a2ab96d6a1c4eb3 |
|
BLAKE2b-256 | f2e98f9f76dd13a4d8f7d036d11435920ca5729ac11e9af6ef786f3bf1392c88 |