class permForm(forms.Form):
def __init__(self, data=None, **kwargs):
super(permForm, self).__init__(data, **kwargs)
for item in list(AdminMenu.objects.filter(parent_id=0)):
self.fields['menu_%d' % item.id] = forms.BooleanField(label=item.title)
for childitem in list(AdminMenu.objects.filter(parent_id=item.id)):
arr=[]
arr.append(str(item.id))
arr.append(str(childitem.id))
self.fields['menu_%s' % '_'.join(arr)] = forms.BooleanField(label=childitem.title)
It will return
category: checkbox
add category: checkbox
List Category: checkbox
Food: checkbox
Add Fooditems: checkbox
Fooditem list: checkbox
Tables: checkbox
Add tables: checkbox
List of tables: checkbox
Users: checkbox
Browse users: checkbox
How can I display it as the following
category: .
add category: checkbox
List Category: checkbox
Food : checkbox
Add Fooditems: checkbox
Fooditem list: checkbox
Tables : checkbox
Add tables: checkbox
List of tables: checkbox
Users : checkbox
Browse Users: checkbox
I WANT TO MAKE A LOCAL CATEGORY OF PARENTS WHICH REFUSES TO CHILD. POSSIBLE? I DO NOT WANT TO USE HEAVY ENCODED FORMS
sumit source
share