Wednesday, December 29, 2010

Re: merge 2 views?

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-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