[Answered ]-Filter ForeignKeyFeild Choices in field by value in other field

2👍

Technically, this is no longer in the realm of Django. Once the page is rendered, Django is done. Anything like this requires JavaScript and specifically AJAX. You just create a view to return neighborhoods for a city in JSON, then use AJAX to fetch that response whenever the city selectbox’s onchange event is fired. Use use the JSON to construct new options for the neighboorhood selectbox, and then replace the old options with that.

There’s a million questions on StackOverflow regarding how to specifically do all that — many written by myself.

Leave a comment