Задать вопрос

Тел: +7 965 3737 888

536

Просмотров

1

Ответов

Slightly better media path tag

<p>A slightly improved version of <a href="https://djangosnippets.org/snippets/195/">snippet #195</a> which keeps the logic but makes use of the simple_tag decorator to drastically simplify the code.</p>
<p>For an alternative to this sort of tag, check out the media context processor in my <a href="http://code.google.com/p/django-template-utils/">template_utils app</a>.</p>

Вопрос полезен? Да0/Нет0
file_5092.py(333.0б)
None

Ответы (1):

Ответtimnik:18.07.2008
Ответ полезен? Да0/Нет0

This is now obsolete. You only need to import RequestContext in your views:

from django.templates import RequestContext

And then add a context_instance to your render_to_response, like so:

return render_to_response('main/main.html', {"variable": 0}, context_instance=RequestContext(request))

You can now access the media url anywhere with {{ MEDIA_URL }}