Re: Referencing MEDIA_URL from templates

2005-10-04 Thread kmh
Some examples of use (mis-use?) cases for making settings accessible to templates: 1. To avoid hard coding media url domains in your templates when you're moving between different test and production server setups. 2. To use, for example, the ADMIN_EMAIL setting in a generic error template that

Re: Referencing MEDIA_URL from templates

2005-10-04 Thread Maniac
Adrian Holovaty wrote: Right now, there's no other way to get to MEDIA_URL, because it's intended to be used only by the FileFields. Out of curiosity, what's your use case for using it otherwise? For the same thing that admin site uses admin_media: referencing stylesheets and javascripts.

Re: Referencing MEDIA_URL from templates

2005-10-04 Thread kmh
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'. Usa

Re: Referencing MEDIA_URL from templates

2005-10-04 Thread Adrian Holovaty
On 10/4/05, Maniac <[EMAIL PROTECTED]> wrote: > What's the recommended (if any) way to reference MEDIA_URL defined in > settings file from templates? MEDIA_URL is used by all FileFields to give their objects a get_FOO_url() method. See this page: http://www.djangoproject.com/documentation/db_api

Re: Referencing MEDIA_URL from templates

2005-10-04 Thread Maniac
Matt wrote: good question. looking at the {% debug %} output I'd hoped that this would work: {{ myproject.settings.main.MEDIA_URL }} It doesn't look to me that it should... Those modules in debug aren't in a Context, they are in a different dict that I suspect is not available outside of

Re: Referencing MEDIA_URL from templates

2005-10-04 Thread Matt
good question. looking at the {% debug %} output I'd hoped that this would work: {{ myproject.settings.main.MEDIA_URL }} but it doesn't output for me.

Referencing MEDIA_URL from templates

2005-10-04 Thread Maniac
What's the recommended (if any) way to reference MEDIA_URL defined in settings file from templates? Admin site uses custom template tag for it. Is there anything similar for general usage in projects?