After read you I've decided to do a tag, I think that it's the best way to do 
it. About the calls to the database I can that it's no problem because in the 
future I could use cache system so it's no problem.

Thanks for your help and recommendations, it's been very good and I'm so happy 
with this group.

If my job give me some free time, I'll try to participate more.

>On Wednesday 11 February 2009 22:44:52 Michael Newman wrote:
> > Hi all,
> >
> > I'm new in this group and I have to say that my English is very poor
> > so sorry.
>
> Welcome to the group!
>
> > I've the follow problem, I want to put in one of my base templates
> > (that it's include in main base template) a list of one model, for
> > example a Category model that has a relationship with other model like
> > Post (this has a ForeignKey with Category).
> >
> > I can do it by two ways. I can create a context processor where I can
> > retrive all category's objects and put them in the context so I could
> > access them through all templates, or I can make a new tag where I can
> > do the same and use it in that template.
>
> As a general rule context processors are great when you need the
> information on any page at any given time. Template tags are good when
> you need information in certain places.
>
> > I don't know which is better and why, and if you've other ideas to do
> > it I'm very interested in know them.
>
> In reality they both do the same thing and it is up to you how they
> work. Think of it as over head. Without any caching in place a context
> processor will make a call to the database (or multiple calls) for
> every page that is loaded. A template tag will only be loaded on the
> pages you load it on and only call the database when you call the tag.
> it up to you if you need it that much.
>
> I recommend you use django-logging and view your SQL queries. It is
> always a good thing to see if your page loads are much heavier than
> you expect. Then you can decide on how you want to hit your db,
> whether it be with a selectively chosen template tag or a brute force
> context processor.
>
> > Thanks and sorry about my english.
>
> No problem and don't be sorry, your English is great,
>
> Michael
> 
-- 
David Basoko


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to