Re: Is there any way to associate a view with a template?

2007-07-29 Thread Emanuele Pucciarelli <[EMAIL PROTECTED]>
Hi Dan, > make a view for the nav.html template (which is included in all the > page templates)? I imagine it could be done with SSI but I don't want > to go that route unless I have no other option. Carole's advice solves your problem just right; on the other hand, you might want to look at

Re: Is there any way to associate a view with a template?

2007-07-28 Thread Eloff
On Jul 28, 1:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Yeah I was going to post a sample if that's what he said next :) Here > is another sample in addition to the link above .. on how to pass the > menu code via context processors: That works great! Thanks a bundle Carole!

Re: Is there any way to associate a view with a template?

2007-07-28 Thread olivier
Hi, > Oh, I do that, but it still requires setting the variable "menu" in > every single view based on that template. You may want to check out Jinja [1], a templating engine very close to the Django one, which enables to set variables in the template. It's not very much advertised here, but

Re: Is there any way to associate a view with a template?

2007-07-28 Thread Eloff
On Jul 28, 12:30 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Why not have a base template that contains the menu variable ( I put > mine in a session variable accessible to the templates named menu ), > then have all of your other templates extend from that template? Oh, I do that, but

Re: Is there any way to associate a view with a template?

2007-07-28 Thread [EMAIL PROTECTED]
Yeah I was going to post a sample if that's what he said next :) Here is another sample in addition to the link above .. on how to pass the menu code via context processors: In your settings.py file ... Find the line that says (there may be more in there depending on your setup):

Re: Is there any way to associate a view with a template?

2007-07-28 Thread Nathan Ostgard
I could be wrong, but I think the problem he's having is having to specify the menu variable in the context for every view, not the template end of it... To fix that, you will want to check out context processors:

Re: Is there any way to associate a view with a template?

2007-07-28 Thread [EMAIL PROTECTED]
Why not have a base template that contains the menu variable ( I put mine in a session variable accessible to the templates named menu ), then have all of your other templates extend from that template? In base.html: your header code {% block menu %} {{ menu }} {%

Is there any way to associate a view with a template?

2007-07-28 Thread Eloff
I've got a nav.html template that does the menu on every page. The only trouble is I have to store the menu items in a global variable and pass it to the page template in every view. Is there any way to make a view for the nav.html template (which is included in all the page templates)? I imagine