In a project I'm working on I have a status bar at the top of the webpage that will render data using template tags. The status bar will be displayed on all of my views, so I want to put the html code in my base template. The base template is imported to all of templates using the 'extends' template tag. Now the base template needs a dictionary of data. My question is, how do I pass this data to the base template? I'm passing it in the context data of every view that renders a template, but it seems like there should be a better way - for example the base template calling out to a python function that can add data to the context before its rendered. Is there any other way to pass data to a base template?
This is exactly what context processors are for:
https://docs.djangoproject.com/en/1.3/ref/templates/api/#subclassing-context-requestcontext
--
DR.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kIKYl-HM83wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment