2

I have to models: "Order" and "Product"; the "Order" contains a "Customer" as foreign key. I create an admin page where Order is the parent and products are shown as inline.

When I add a new istance of products I want that a dropdown is filtered based on the value chosen in the parent "Customer" field.

I've already tried the chained dropdown list with no success; I've also overriden the init method of the inline form but the result is the same. I can't understand what is the metod triggered when I click the "add new" link in inline formset.

Do you have any suggestion on how to achieve the result?

BlueTree
  • 179
  • 1
  • 13
  • If you are using Django Admin you can override Admin.change_view to filter values based on some model. In older versions of Django you could override formfield_for_foreignkey. – André Duarte Dec 06 '19 at 13:07
  • Maybe this helps: https://stackoverflow.com/a/12053145/633961 – guettli Jan 05 '21 at 20:42

0 Answers0