2👍
✅
This is what context processors are for. You’re already using RequestContext, so you just need to define a function that returns your menu and add it to TEMPLATE_CONTEXT_PROCESSORS
.
0👍
Depending on what version of django you are using, you might want to look into class based views or even class based generic views.
Otherwise you can also do something like:
def menu_view(request, template='menu.html', **kwargs)
return render_to_response(template, kwargs,
context_instance = RequestContext(request))
I think kwargs should work just like that. Haven’t tested. If it doesn’t, make a dictionary out of it.
- [Answered ]-Django Endless Pagination – Showing Current Number of Results (not pages)
- [Answered ]-Django IntegrityError with DateTimeField
- [Answered ]-Change Django Rest Framework serializers output structure?
- [Answered ]-Best way to implemente confirmantion and alert messages
- [Answered ]-Handling Multiple Views/ Multiple Urls in Django
Source:stackexchange.com