I want to create a nested dictionary in such a form:
{
    catagory_name: {1: abc, 2: efg},
    category_name: {1: pqr, 2: stu},
    category_name: {1: vwx, 2: ijk, 3: lmn}
}
Where I will fetch category1_name, category2_name and category3_name from a table1 and then I will for loop it to execute new query and fetch values abc, efg, pqr, stu and vwx, ijk, lmn from next table based on Ids fetched from table1.
Something like this:
categories = cat.getAllCatagories()
for value in categories:
    categoriesData = {}
    subCategories = cat.getSubCategoriesByCategoryId(value.id)
    for val in subCategories:
        categoriesData[values.name] = val.name
context = {'categoriesData': categoriesData}
return render(request, 'demo/test/industries_catagories.html', context)
Now I want to access this categoriesData dictionary in my template of Django framework and list it form of tree structure.
Any ideas will be very much appreciated.
Sources I referred SO question are very complicated.