def region_navigation(request, region_path): context = RequestContext(request) # profile_root is the url root for the profiles # probably could use django's lookup thing for this context.profile_root = "/profiles/" country_root_object = region_root_object() context.stylesheets = [] if region_path == "": return HttpResponseRedirect("/profiles/nigeria") #query country for sub sections region_thing_object = country_root_object.find_child_by_slug_array(region_path.split("/")) widget_ids, include_templates = widgets.widget_includes_by_region_level(len(region_thing_object.ancestors())) context.widgets = include_templates context.entity = region_thing_object.entity context.title = "NMIS Profiles: %s" % region_thing_object.name #what goes on behind the scenes that you don't need to edit-- for widget_id in widget_ids: if hasattr(widgets, widget_id): context.__dict__[widget_id] = getattr(widgets, widget_id)(region_thing=region_thing_object, context=context) else: context.__dict__[widget_id] = False return render_to_response("region_navigation.html", context_instance=context)