我有几个视图,每个人都必须像这样渲染动态菜单:
def view1(request):
return render_to_response('view1.html',
RequestContext(request, {'menu': menu, 'a': a, ...}))
def view2(request):
return render_to_response('view2.html',
RequestContext(request, {'menu': menu, 'b': b, ...}))
def view3(request):
return render_to_response('view3.html',
RequestContext(request, {'menu': menu, 'c': c, ...}))
def viewN(request):
return render_to_response('view4.html',
RequestContext(request, {'menu': menu, 'd': d, ...}))
但这很不舒服,因为我必须为每个视图添加菜单属性。我可以通过哪种方式进行优化?