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, and return a Python list

We can then wrap every single view in this decorator, and then pass the list 
to the template for rendering.

Firstly - is there a more elegant alternative, rather than wrapping every 
single view in this decorator? (Middleware? Or is that a poor fit here? 
Anything else?).

And secondly - are there are any performance issues here? We're making 
database calls with every single view, just to get a list for a navigation 
dropdown. Smarter way?

I know I can use the caching middleware to cache entire pages, or even 
template fragments - but how about caching a single list() like this? What 
are other methods people are using to tackle this?

Cheers,
Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/8cKewo2DudcJ.
To post to this group, send email to django-users@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.

Reply via email to