it/itf/frontpage/context_processors.py

13 lines
351 B
Python
Raw Normal View History

2011-08-10 11:40:16 +00:00
from frontpage.models import MenuHeading, MenuItem
def menus(request):
menuHeads = MenuHeading.objects.all()
menus = []
for m in menuHeads:
d = {
'name': m.name,
'items': [{'name': item.name, 'url': item.url} for item in m.menuitem_set.all()]
}
menus.append(d)
return {'menus': menus}