Re: View decorator for common navigation elements?

2011-10-03 Thread Thomas Orozco
Maybe you can use template inheritance and have the base template access the data through, alternatively, template filters or instance methods? To make those work, you can take advantage of the existing template processors (notably the auth one). If you want to not have the topnav on a

Re: View decorator for common navigation elements?

2011-10-02 Thread Victor Hooi
heya, This SO post seems to suggest that data and template tags shouldn't mix... http://stackoverflow.com/questions/5046046/where-put-database-interaction-in-django-templatetags Not sure how I feel about that myself - I see the philosophical argument behind it, but I don't see another more

Re: View decorator for common navigation elements?

2011-10-01 Thread colinta
This post is particularly well timed, since I have the exact same question. I'm excited to say the company has, after many years, been convinced to stop working on our internal PHP framework and we chose django as its replacement (in sad news, I was the main dev on that framework, and poured my

Re: View decorator for common navigation elements?

2011-09-30 Thread Victor Hooi
heya, I do like the idea of just including a custom template tag =). Hmm, can custom template tags interact with models or query the database like that? Firstly, Is it possible, and secondly, is it considered good practice? Cheers, Victor -- You received this message because you are

Re: View decorator for common navigation elements?

2011-09-30 Thread Luis Morales
wouldn't a template tag work best in a case like this? something like {% NavBar %} or {% GetNav NavName %} that way you can have your own cache code inside you template tag code, like storing the database result into memcached or redis and avoid a relational db call each page. them you you

Re: View decorator for common navigation elements?

2011-09-29 Thread Alex Chan
Hi Victor, I think this is a very good question. I've been considering what the best approach would be and decided on either using a decorator as you've mentioned or implementing class based views. You can create base view classes that load common data for the different types of pages. You

View decorator for common navigation elements?

2011-09-29 Thread Victor Hooi
Hi, We have a common navigation bar on nearly every page (view) that contains a dropdown - this dropdown is populated with items from a database table. This dropdown also has AJAX behaviour attached to it. I'm thinking I can create a decorator that will retrieve the list from the database,