Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-postal

How to install django-postal

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-postal
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.9
0.93Never BuiltWhy not?
0.9 Available View build log
0.8 Available View build log
0.7.9 Available View build log
0.7.8 Available View build log
0.7.7 Available View build log
0.7.6 Available View build log
0.7.3 Available View build log
0.6.2 Available View build log
0.6.1 Available View build log
0.5.3 Available View build log
Windows (64-bit)
0.9
0.93Never BuiltWhy not?
0.9 Available View build log
0.8 Available View build log
0.7.9 Available View build log
0.7.8 Available View build log
0.7.7 Available View build log
0.7.6 Available View build log
0.7.3 Available View build log
0.6.2 Available View build log
0.6.1 Available View build log
0.5.3 Available View build log
Mac OS X (10.5+)
0.93 Available View build log
0.92 Available View build log
0.9 Available View build log
0.8 Available View build log
0.7.9 Available View build log
0.7.8 Available View build log
0.7.7 Available View build log
0.7.6 Available View build log
0.7.3 Available View build log
0.6.2 Available View build log
0.6.1 Available View build log
0.5.3 Available View build log
Linux (32-bit)
0.93 Available View build log
0.92 Available View build log
0.9 Available View build log
0.8 Available View build log
0.7.9 Available View build log
0.7.8 Available View build log
0.7.7 Available View build log
0.7.6 Available View build log
0.7.3 Available View build log
0.6.2 Available View build log
0.6.1 Available View build log
0.5.3 Available View build log
Linux (64-bit)
0.93 Available View build log
0.92 Available View build log
0.9 Available View build log
0.8 Available View build log
0.7.9 Available View build log
0.7.8 Available View build log
0.7.7 Available View build log
0.7.6 Available View build log
0.7.3 Available View build log
0.6.2 Available View build log
0.6.1 Available View build log
0.5.3 Available View build log
 
License
BSD
Depended by
Lastest release
version 0.93 on Nov 23rd, 2012

django-postal

(Based upon http://github.com/mthornhill/django-postal)

WARNING: This project is in ALPHA mode and the API is in flux.

A django application that provides a location agnostic model for postal addresses.

The motivation behind this project is that most countries have different forms of postal addresses e.g. http://www.bitboost.com/ref/international-address-formats.html , http://en.wikipedia.org/wiki/Address_%28geography%29

This app assumes that all postal addresses worldwide can be made up of 5 optional address lines plus a country code.

It then localizes the title of each line dependant on the country selected. Further information on each address line can be gleaned from django.contrib.localflavor fields and widgets e.g. for the UK

from django import forms from django.utils.translation import ugettext_lazy as _ from django.contrib.localflavor.uk.forms import UKPostcodeField, UKCountySelect

from postal.forms import PostalAddressForm

class GBPostalAddressForm(PostalAddressForm):
line1 = forms.CharField(label=_(u"Street"), required=False, max_length=50) line2 = forms.CharField(label=_(u"Area"), max_length=50) city = forms.CharField(label=_(u"Town"), max_length=50) state = forms.CharField(label=_(u"County"), widget=UKCountySelect, max_length=50) code = UKPostcodeField(label=_(u"Postcode"))

It is hoped that various contributors will contribute address formats per country and that eventually this address information could find it's way back in to django.contrib.localflavor

Dependencies

django-countries (http://pypi.python.org/pypi/django-countries)

Usage

1. Add django-countries and django-postal to your INSTALLED_APPS in settings.py e.g.

INSTALLED_APPS = (
"countries", "postal", ... )
  1. Add a postal_form to your templates

some_template.html {% load postal_tags %} <html> <head> <script src="{{ MEDIA_URL }}js/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script> </head> <body> <form method="POST" action=""> {% csrf_token %} {{form.as_p}} {% monitor_country_change %} <script type="text/javascript">

System Message: ERROR/3 (<string>, line 70)

Unexpected indentation.
$('form').monitor_country_change('#id_country');

System Message: WARNING/2 (<string>, line 71)

Block quote ends without a blank line; unexpected unindent.

</script> <input type="submit"/> </form> </body> </html> Changing the country in the form above should localise the address form.

  1. In your view code add code to save the addressform e.g.

from postal.forms import PostalAddressForm

def my_view(request)
if request.method == "POST": address_form = PostalAddressForm(request.POST, prefix=request.POST.get('prefix', '')) address_form.save()

How to use localised addresses

Address localisation is turned on by default. To turn off Address l10n: in settings.py set

System Message: ERROR/3 (<string>, line 94)

Unexpected indentation.
POSTAL_ADDRESS_L10N = False
Customize address labels and requirement

If you wish to customize the address labels and whether the address line is required or not, you can add the following variables to settings.py

System Message: ERROR/3 (<string>, line 103)

Unexpected indentation.
POSTAL_ADDRESS_LINE1, POSTAL_ADDRESS_LINE2, POSTAL_ADDRESS_CITY, POSTAL_ADDRESS_STATE, POSTAL_ADDRESS_CODE

each of these variables is set to a tuple of the format ('label', True/False) 'label' is used to label the field, and the second boolean value sets whether the field is required or not, e.g.

System Message: ERROR/3 (<string>, line 109)

Unexpected indentation.
POSTAL_ADDRESS_LINE1 = ("Department", True)

BUILD HISTORY

0.7.2 Major refactor where all models removed so django-postal just provides localized forms. It is up to the supporting project to define their own address models

0.4 Don't enforce uniqueness on postal addresses

Developers, How to Contribute

$ git clone git@github.com:mthornhill/django-postal.git $ cd django-postal $ virtualenv . --no-site-packages $ source bin/activate $ python bootstrap.py $ bin/buildout -v $ bin/django syncdb $ bin/django test postal $ bin/django runserver

browse to http://localhost:8000

new countries can be added to the src/postal/forms folder by their 2 letter country code e.g. us

Each country folder contains an __init__.py and a forms.py forms.py contains the localized address

Subscribe to package updates

Last updated Nov 23rd, 2012

Download Stats

Last month:8

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.