On Wed, Mar 11, 2009 at 4:54 PM, AKK <andrewkenyon...@gmail.com> wrote:
> > Hello, > > I have a number of views and templates and a list of categories which > i get from my models using: > > categories_list = categories.objects.all() > > Since i need to display this in multiple (but not all) templates is > there a better way to achieve this than just putting; categories_list > = categories.objects.all() in all my views? And if there is how can i > do it? > > Thanks, > > Andrew > > > You could write a template context process that does this(see the docs for more info on them). The great thing about this is ebcause of the way querysets work you won't even have the overhead of an extra SQL query unless you use it since the queryset won't evaluate unless it's used :) Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---