Write your own context_processor for that reason. This is a quick example:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# this is a file yourproject/yourapp/context_processors.py
import re
from django.conf import settings
def general(request=None):
return {
'root_dir': settings.ROOT_DIR,
'media_url': settings.MEDIA_URL,
}
and then link to it in the settings:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.request",
"yourproject.yourapp.context_processors.general",
)
>From now on {{ root_dir }} and {{ media_url }} will be accessible in
all templates.
Good luck!
Aidas Bendoraitis [aka Archatas]
On 8/23/07, Filipe Correia <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> Regarding template inheritance and the use of {% extends %}, in the
> Django book[1] says that:
>
> "In most cases, the argument to {% extends %} will be a string, but it
> can also be a variable, if you don't know the name of the parent
> template until runtime. This lets you do some cool, dynamic stuff."
>
> What I am trying to do is to pass an extra variable to every template
> (which I have defined in settings.py), so that I can use that value
> with {% extends%}.
>
> What is the best way to accomplish this; will I have to change all of
> my views to pass the extra var?
>
> thanks,
> Filipe
>
> [1] http://www.djangobook.com/en/beta/chapter04/#cn356
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---