Retrieving cities belonging to the selected country for the initial request

I only need to return the Cities belonging to the currently selected country.

Any idea how I can do this?

I understand that I need to use JavaScript to update the list, but how can I do this for the initial request, given that I load the entire field in my view using: {{profile_form.city}}

The city model has a foreign key for the country.

Your help would be appreciated.

+3


source to share


1 answer


Check out this app, make sure it helps you a lot and you can save a lot of time https://github.com/dpnova/django-simple-cities .



+2


source







All Articles