furious-luke / django-address

A Django address model and field. Addresses may be specified by address components or by performing an automatic Google Maps lookup.
BSD 3-Clause "New" or "Revised" License
428 stars 178 forks source link

Add address settings #163

Open karimone opened 2 years ago

karimone commented 2 years ago

Prior to this change to modify the address javascript you had to fork and edit the address.js manually. This change let to define a setting dict to customize the address.js.

e.g.

ADDRESS_SETTINGS = {
    'country': ['AU'],
}

it will be injected in the address.js to limit the address to the australian country.

To achieve that I move the address.js from a static file to a templateview and threat the address.js file as a django template.

The TemplateView is responsible to retrieve the settings and generate the context for the template.

There is a requirement to make django-address works now. The url must be added in your project:

e.g.

urlpatterns = [
    # ... other urls
    path('address/', include('address.urls')),
]
karimone commented 2 years ago

I did some tests and I have a circular import issue, I'll have a look