Ticket #346: mediaurl.py
File mediaurl.py, 423 bytes (added by , 19 years ago) |
---|
Line | |
---|---|
1 | from django.core import template |
2 | |
3 | class MediaURLPrefixNode(template.Node): |
4 | def render(self, context): |
5 | try: |
6 | from django.conf.settings import MEDIA_URL |
7 | except ImportError: |
8 | return '' |
9 | return MEDIA_URL |
10 | |
11 | def media_url_prefix(parser, token): |
12 | """ |
13 | {% media_url_prefix %} |
14 | """ |
15 | return MediaURLPrefixNode() |
16 | |
17 | template.register_tag('media_url_prefix', media_url_prefix) |