On 15 jan, 23:14, Tim Chase <[EMAIL PROTECTED]> wrote:
> > The thing is, in my sidebar I want to display all the categories. This
> > sidebar is the same for every view. How do I create the variables
> > needed for this recurring sidebar? So that in every view I can
> > generate a list of all categories in the database?
>
> It sounds like you're interested in one of two things:
>
> 1) template inheritance:  you can define a base template that has
> the skeleton of your site (headers, and the above-mentioned
> side-bar with categories), and then other templates can use this
> as the base for their content.
>
> http://www.djangoproject.com/documentation/templates/#template-inheri...

This is indeed what I'm doing right now. But this is more for design
purposes. I wanted to populate the blocks of the base template with
variables, without declaring that variables in every view with
extra_context for example.

> 2) template tags:  these abstract away chunks of rendering logic
> that can be reused.
>
> http://www.djangoproject.com/documentation/templates_python/#writing-...
>
> Most likely, you want #1 for your purposes.  Just make sure that
> the variables used to render each your templates are put in the
> context that's passed to the template.

This seems what I'm looking for. I'm going to define my own template
tags which shows the categories available. This is the most DRY way to
do it I think.

Thank you for pointing me in the right direction.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to