Category and Sub Category Cascading

Hello everyone,

I am trying to build a form wherein the user selects Category, and if Subcategory is available then it will be shown in another dropdown which includes category as well to select.

If there is no sub-category then the dropdown should hide.

I am new to web development, please guide

This is primarily a JavaScript issue and not a Django issue. That type of dynamic UI can only be effectively managed in the browser by using JavaScript to retrieve the subcategories when a category is selected.

(Note: Technically, this is not precisely nor completely accurate. There are two alternatives for handling this without using AJAX to retrieve additional data. You could include all the data in your initial form rendering, then have JavaScript alter the set of active options depending upon the selected category. Or, you could turn this into a multi-page process where selecting a category takes you do a new page where the subcategory is rendered based upon the selected category.)

For a django-assisted solution, check out for “cascade” or “dependent” select boxes. There are some packages that have been built to assist creating solutions for this.

thanks Ken, I had build the solution in MS Access was trying to migrate into web solution.
I am trying not to use any packages.
I have built a small solution wherein subcategory is populated by selecting Category, but here the tweek is “user wants both category and sub category” in sub category dropdown once Category is selected. Anyways, let me look for alternative in Javascript. Thanks for your time.