Thanks for the solution =) but on everypage the navigation will be called so there wont be unneccecary code, Thanks for the tip though will surely look at it for some other project
On 1 jan, 08:01, Sam Lai <samuel....@gmail.com> wrote: > The one downside to this solution is that these variables will fetched > for every request, even if navigation.html was not included in the > output template. > > An alternative solution would be to create a template tag that fetches > these variables, and only load and use this template tag in > navigation.html. That way those variables are only fetched if > navigation.html is included. > > It's a little bit more complicated in code though (made a lot easier > in Django 1.3 with simple_tag), and might not be worthwhile if you > aren't doing complicated computations. > > http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ > > On 30 December 2010 05:32, Thom van Ledden <tvled...@gmail.com> wrote: > > > > > > > > > Thanks a lot for pointin me in the right direction! > > > made a context_processor.py for my navigation, and added it to my > > settings.py > > > from basic.blog.models import Category > > from common.models import fillNavigationFinishedProjects > > from common.models import fillNavigationUnfinishedProjects > > > def navigation(request): > > """ > > Adds navigation variables to the context. > > > """ > > return { > > 'finishedProjects':fillNavigationFinishedProjects(), > > 'unfinishedProjects':fillNavigationUnfinishedProjects(), > > 'blogCategories':Category.objects.all(), > > } > > > Seems to work perfectly! > > thanks much! > > > On 29 dec, 18:51, Michael <mhall...@gmail.com> wrote: > >> Look into context processors, that sounds like what you need. > > >>http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-c... > >> -- > >> Michael <mhall...@gmail.com> > > >> On Wed, 2010-12-29 at 08:51 -0800, Thom van Ledden wrote: > >> > Hi django developers, > > >> > Ive got a seperate navigation.html file which need to be rendered on > >> > each page, but the page need some vars for that. how can i get those > >> > vars to be defined just only once? > > >> > my idea: the main_page should add the vars for the navigation, and the > >> > views of the content pages will have their own vars, and those need to > >> > be merged some how > >> > some files i uploaded:http://thomvl.pastebin.com/gGjGj4NP > >> >http://thomvl.pastebin.com/uYUp5iCjhttp://thomvl.pastebin.com/Yv6fPTP7 > > >> > could anyone point me where i go wrong? (the main_page 's vars are the > >> > ones i need, aside of title ofcourse) > > >> > Thanks in advance > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.