My scenario:
I'm having three tables, Category, Subcategory, Products. While inserting new product, there are two select boxes
1)1st select is for Category (its working)
2) 2nd is for Subcategory, which should be relevant to the 1st select. Needs to fetch the data from subcategory table.
Subcategory table has category id as a foreign key. I am a beginner, please somebody help.
Updated for django 2.1 but not working and thanks to Satendra. I can not comment above thats why submitted my problem as answer
For filling this subcategory field, you have to create a view which will respond with json data.
At urls.py you need to add a pattern to reach the view:
Now you have to override change_from.html of django admin for your product app to add some JS code to do the magic.
In your change_form.html, write somethings like this: