scaleway / postal-address

:postal_horn: Parse, normalize and render postal addresses.
https://postal-address.readthedocs.io
Other
183 stars 16 forks source link

Django integration? #17

Open moul opened 7 years ago

moul commented 7 years ago

Hi @kdeldycke and @scaleway,

Do you think we could use this library to create a Django PostalAddressField? Could you write some documentation, snippet or maybe a library for this?

kdeldycke commented 7 years ago

Sorry @moul, never wrote a single line of code within the Django ecosystem so I can't really help you there. That being said, I'll welcome any contribution to work toward that goal.

As of integrating the Django boilerplate code directly in this repository, it depends on its nature. If it's lightweight and doesn't prevent usage of postal-address as a stand-alone Python module, why not. Else, it might be better to create a side project to wrap postal-address and provide a proper Django field.

shaleh commented 5 years ago

A Field is likely not what you want. Fields map to a column in a database. I suspect most people don't want their normalized addresses stuffed into a database as a string.

A more sensible approach would be to make a Django package that wraps this package and supplied a PostalAddress model. Then the individual parts of the address would be represented as independent fields in a table. Now someone could select distinct(country_code) from postal_address or in Django ORM french_connections = PostalAddress.objects.filter(country_count='FR').count().

What anyone interested would need to do is make a django-postal-address package and add a PostalAddress and Territory model. These would look a lot like the objects in this package with additions like date_created. Add a method to the models to create one from the PostalAddress or Territory object and to create a PostalAddress or Territory from the models.