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
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
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
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
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
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
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,
7 matches
Mail list logo