I either do something like this:
---
class SettingsNode(Node):

   def render(self, context):
       from django.conf import settings
       context['settings'] = settings
       return ''

def do_put_settings(parser, token):

   """
   Put the site settings into the context as 'settings'.

   Usage::

       {% put_settings %}
   """

   argv = token.contents.split()
   if len(argv) != 1:
       raise TemplateSyntaxError, "put_settings takes no arguments"
   return SettingsNode()

register_tag('put_settings', do_put_settings)
---
Then you can do:

{% load mytags %}
{% put_settings %}

{{ settings.MEDIA_URL }}

Or else put the site settings in a custom Context.

It seems like a common requirement and a standard way would be good.  I
wonder if site settings should be available in the DjangoContext? Or
perhaps just a documented "right way" would do the job.

Kieran

Reply via email to